The following two examples illustrate the potential use for the Expansion element.
Example 1: Implementing a rule to standardize the case of text entered in a field
Example 2: Hiding expansion logic
Expansion rules transform information that has been entered into a field into values that match the format expected by the resource or established by a rule. For example, a free-form text box in which a user enters a name can include an Expansion rule that capitalizes the first initial and lowercases the others.
The use of the global attribute in fields sets any of the resources that have this value when the form is saved. When you load this form, Identity Manager loads the values from each resource (unless the field is disabled). The last resource load sets the value in the form. If a user has made a local change, this change may not show up. Consequently, to ensure that the correct value for the attribute is used, you can use a Derivation rule to specify one or more of the resources as an authoritative source for the field.
<Field name=’global.lastname’> <Display class=’Text’> <Property name=’title’ value=’Last Name’/> <Property name=’size’ value=’32’/> <Property name=’maxLength’ value=’128’/> <Property name=’noNewRow’ value=’true’/> <Property name=’required’> <Boolean>false</Boolean> </Property> </Display> <Expansion> <block> <defvar name=’lname’> <downcase> <ref>global.lastname</ref> </downcase> </defvar> <defvar name=’nlength’> <sub> <length> <ref>global.lastname</ref> </length> <s>1</s> </sub> </defvar> <concat> <substr> <upcase> <ref>global.lastname</ref> </upcase> <s>0</s> <s>1</s> </substr> <substr> <ref>lname</ref> <s>1</s> <ref>nlength</ref> </substr> </concat> </block> </Field>
As the preceding XPRESS logic could be implemented in multiple fields, consider presenting it in a rule.
In the following example, this field is also hidden by the absence of any Display class definition. The lack of Display class definition prevents the field from being displayed in the form, but the field is still considered to be an active part of the form and will generate values for resource attributes through its <Expansion> expression.
<Field name=’accounts[Oracle].locCode’> <Expansion> <switch> <ref>location</ref> <case> <s>Austin</s> <s>AUS</s> </case> <case> <s>Houston</s> <s>HOU</s> </case> <case> <s>Dallas</s> <s>DAL</s> </case> </switch> </Expansion> </Field>
In this example, it performs the reverse of the mapping performed by the location field.