In certain forms, you might want to first display a set of abstract derived fields to the user, then generate a different set of concrete resource account attribute values when the form is submitted. This is known as form expansion. An <Expansion> element is typically used in hidden fields that depend on editable fields in the form. One purpose of the <Expansion> element is to convert data that is familiar and readable to an end-user into data that is recognized by a resource. For example, a user can see a manager’s full name in the form, but the system receives a unique ID that it recognizes as belonging to a manager.
The following example shows a field definition that uses conditional logic to convert the value derived for the location field in the previous example back into a three-letter abbreviation.
<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>
The <Expansion> element is part of the Form XML language and can contain an expression. When this field is processed, the expression in the <Expansion> element is evaluated to determine the value of the field.
In this example, this element performs the reverse of the mapping performed by the location field. This field is also hidden by the absence of an assigned Display class. This lack of Display class 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.
For all forms except the User view, Expansion rules are run whenever the page is recalculated or the form is saved. For the User view, an <Expansion> tag runs when the userform is first loaded as well.