Sun Identity Manager Deployment Reference

Declaring a Rule with Arguments

Best Practice:

You are not required to declare arguments for a rule, but it is considered a best practice to do so. If a rule uses a variable that is “in scope” at the time of the rule’s execution, then the rule becomes less reusable.

Declaring arguments in a rule provides documentation to rule users, allows reference validation in the Identity Manager IDE, and allows the rule to be used in forms and workflows that might not use the same naming convention.

You can use the <RuleArgument> element to declare rule arguments, and set a default value for the argument by specifying a value after the argument name. For example, the following rule specifies “Austin” as the default value for the location RuleArgument.

Example 4–12 Setting a Default Value

<Rule name=’description’> 
   <RuleArgument name=’UserId’/> 
   <RuleArgument name=’location’ value=’Austin’/> 

You can use this rule in user forms, but UserId and location are not attributes of the User view. You must use the <argument> element in the rule call to pass the expected arguments into the rule. Note that passing an argument whose name is location overrides the default value declared in the RuleArgument element in the rule definition.

Example 4–13 Overriding a Default Value Declared in RuleArgument

<rule name=’description’> 
   <argument name=’UserId’ value=’$(waveset.accountId)’/> 
   <argument name=’location’ value=’global.location’/> 

For more information about calling rules, see Referencing Rules.

There is no formal way to declare an argument type, but you can specify type in a comment field. Use the <Comment> element to include comments in your rule:

Example 4–14 Using <Comment> to Include Comments in a Rule

<Comments> Description rule is expecting 2 arguments. 
A string value UserId, which is the e employees’ ID number, and a 
string value location that describes the building 
location for the employee </Comments>

If you are using the Identity Manager IDE to edit rules, you might find it helpful to formally define a list of rule arguments. This list would consist of the names of variables that are expected to be available to the rule. You can use them afterwards to perform validation in the Identity Manager IDE.