Sun Identity Manager Deployment Reference

Calling Scope or Explicit Arguments in Forms

This section provides examples that illustrate how rule arguments are resolved in forms.

The following example shows how to add a rule to a form. You can use this form with the User view because there are attribute names in the view.


<Rule name=’generateEmail’>
   <concat>
      <ref>global.firstname</ref>
      <s>.</s>
      <ref>global.lastname</ref>
      <s>@example.com</s>
   </concat>
</Rule>

This rule references two variables:

You can call this rule in a Field, as shown in the following example:


Example 4–17 Calling the Rule in a Field


<Field name=’global.email’> 
   <Expansion> 
      <rule name=’generateEmail’/> 
   </Expansion> 
</Field>

This method can be a convenient way to write simple rules that are used in user forms only— similar to the concept of global variables in a programming language. But there are two problems with this style of rule design. First, it is unclear to the form designer which variables the rule will be referencing. Second, the rule can be called only from user forms because it references attributes of the User view. The rule cannot be called from most workflows because workflows usually do not define variables named global.firstname and global.lastname.

You can address these problems by passing rule arguments explicitly, and by writing the rule to use names that are not dependent on any particular view.

The following example shows a modified version of the rule that references the variables firstname and lastname:


Example 4–18 Rule Referencing firstname and lastname Variables


<Rule name=’generateEmail’> 
   <RuleArgument name=’firstname’/> 
   <RuleArgument name=’lastname’/> 
   <concat> 
      <ref>firstname</ref> 
      <s>.</s> 
      <ref>lastname</ref> 
      <s>@example.com</s> 
   </concat> 
</Rule>

The following examples shows a rule that is simpler and more general. The example does not assume that the rule will be called from a user form, but that the rule must be called with explicit arguments.


Example 4–19 Calling the Rule with Explicit Arguments


<Field name=’global.email’> 
   <Expansion> 
      <rule name=’generateEmail’> 
         <argument name=’firstname’ value=’$(global.firstname)’/> 
         <argument name=’lastname’ value=’$(global.lastname)’/> 
      </rule> 
   </Expansion> 
</Field>

The name attribute of the argument elements correspond to the variables referenced in the rule. The values for these arguments are assigned to values of global attributes in the User view, which keeps the rule isolated from the naming conventions used by the calling application and makes the rule usable in other contexts.