Sun Identity Manager Deployment Reference

Using Rules in Forms

You typically call a rule in forms to calculate the value of a field or to control field visibility within a <Disable> expression. Within forms, rules could be the most efficient mechanism for storing and reusing:

When calling rules from forms, it is particularly important that you properly secure those rules. Imagine a rule used in a critical form, but the implementation of the rule could be modified by anyIdentity Manager user! For information about securing rules, see Securing Rules.

The following example rule returns a list of job titles.


Example 4–2 Returning a Job Titles List


<Rule name=’Job Titles’> 
   <List> 
      <String>Sales</String> 
      <String>Accounting Manager</String> 
      <String>Customer Service Representative</String> 
   </List> 
</Rule>

Rules such as this are often used in Identity Manager forms to calculate lists of names for selection. To add or change a new job title, you only have to modify this rule instead of modifying each form that references the rule.

In the next example, the global.jobTitle field calls the Job Titles rule defined in Using Rules in Forms to use the job titles list in a select box:


Note –

This example uses a lowercase r in the rule element because you are calling a rule, not defining a rule.



Example 4–3 Using a Job Titles List in a Select Box


<Field name=’global.jobTitle’> 
   <Display class=’Select’> 
      <Property name=’title’ value=’Job Title’/> 
      <Property name=’allowedValues’> 
         <rule name=’Job Titles’/> 
      </Property> 
   </Display> 
</Field>

Identity Manager forms also support rules that dynamically calculate the name of another rule to call. The following example shows how a form field calls a rule that calculates a department code:


Example 4–4 Calling a Rule that Calculates a Department Code


<Field name=’DepartmentCode’> 
   <Display class=’Text’> 
      <Property name=’title’ value=’DepartmentCode’/> 
   </Display> 
   <Expansion> 
      <rule> 
         <cond> 
            <eq> 
               <ref>var1</ref> 
               <s>Admin</s> 
            </eq> 
            <s>AdminRule</s> <s>DefaultRule</s> 
         </cond> 
      </rule> 
   </Expansion> 
</Field>