Sun Identity Manager Deployment Reference

Writing Rules in JavaScript

When rules become complex, you might find it more convenient to write those rules in JavaScript rather than XPRESS, and then wrap the JavaScript in an XPRESS <script> element.

The following example references the values of form and workflow variables, calls the env.get function, and passes the variable name. The example uses the env.put function to assign variable names, and the value of the last statement in the script becomes the value of the rule. The rule returns the value in the email variable.

Example 4–16 Wrapping JavaScript in a <script> Element

<Rule name=’Build Email’> 
   <script> var firstname = env.get(’firstname’); var lastname = env.get(’lastname’); 
var email = firstname.substring(0, 1) + lastname + ""; email; </script> 

You can call other rules with the function.