Variable Definitions
The recommended best practice is to identify all variables for the workflow at the top of the XML document. The variable definitions come next in the XML.
At a minimum, variable elements require a name. Other attributes can indicate the variable type and use, such as input, required, editable, and return. A description can be specified for each variable. When needed, an initialization value can also be provided. Using the initialization option is the recommended practice rather than creating separate steps to initialize each variable. Using initialization values is more efficient, easier to read, and easier to debug, because Trace reports initializations as they occur. For more information, see Initializer Options .
<Variable input="true" name="project" output="true" required="true">
<Description>
Project that has account requests in the QUEUED state.
</Description>
</Variable>
<Variable editable="true" initializer="true" name="doProvisioning">
<Description>Set to true to cause immediate provisioning after the assignment</Description>
</Variable>
Some parts of the variable definition are expressed within attributes on the Variables element. Other parts are expressed through nested elements of their own.

Variable Attribute |
Purpose |
name |
Variable name. |
type |
Variable type. Type declaration is not enforced by the application and is used primarily for documentation. |
initializer |
Initialization value for the field. |
input |
Flag indicating that the variable is an argument to the workflow. Omitted if not true. |
output |
Flag indicating that the variable is a return value for the workflow. Omitted if not true. |
required |
Flag indicating that the variable is a required field for the workflow. Omitted if not true. |
editable |
Flag indicating that the variable can be edited by the workflow. Omitted if not true. |
Nested Tag within Variable Element |
|
Description |
Provides a description of the purpose for the variable. |
Script |
Alternative to script in the initializer attribute value. Should be used for initializer scripts of any length or complexity. |
Source |
Nested within the Script tag and contains the java BeanShell source for the action to be executed. |

The Initializer attribute requires additional attention. When these attributes are set through the user interface, you can specify the attribute as a string, script, rule, call, or reference. The same options are available directly through the XML.
Note: The initializer for a variable is only used when a value for the variable is not passed in to the workflow.

Initializer Type |
Description and Examples |
string |
Assigns a literal value to the variable. String is the default initializer option so the "string:" prefix can be included or omitted. Examples: <Variable initializer="spadmin" input="true" name="fallbackApprover"> |
script |
Assigns a value based on the results of a Java BeanShell script. Examples: (1) In-line Script. Only use for very short, simple scripts. <Variable initializer="script:(identityDisplayName != void) ? identityDisplayName : resolveDisplayName(identityName)" input="true" name="identityDisplayName"> (2) Script within nested <script> element. Use for most script initializers – scripts of any complexity or length.
<Description> The displayName of the identity being who started this workflow. Query for this using a projection query and fall back to the name. </Description> <Script> <Source> // Lookup the launcher's display name for use in email templates. String returnString = launcher; Identity launcherId = context.getObject(Identity.class, launcher); if (null != launcherId) { returnString = launcherId.getDisplayName(); // First+Last } return returnString; </Source> </Script> </Variable> |
rule |
Assigns a value based on the return value of a workflow Rule. Examples: <Variable initializer="rule:wfrule_GetIdentityName" name="IdentityName"> |
call |
Assigns a value based on the return value of a call to a workflow library method. Example: <Variable initializer="call:getObjectName" name="roleName"> |
ref |
Assigns a value based on a reference to another workflow variable. This type is rarely used. Example: <Variable initializer="ref:otherVar" name="myVar"/> |