Create a variable
You can create user-defined variables from the Action configuration window when you are configuring a workflow action or from the toolbar of the designer page.
Jump to:
Create a variable during action configuration
- In the Action configuration window, click in a field that accepts variables.
- Do one of the following depending on the method available;
- On the drop-down list that appears, Click Create New Variable.
- On the Insert Reference pane that appears, expand the Workflow Variables section and click Create New Variable.
- Do the following in the Workflow Variables pane to create the variable:
- For Name, type the variable name you want to use.
- Select a Type.
- If you want to display the variable on the start form, select the Show on start form check box.
- Click Create.
Create a variable from the designer toolbar
- On the toolbar of the Designer page, click Variables. The Variables dialog box appears.
- Click New and fill in the following:
- For Name, type the variable name you want to use.
- For Type, select a variable type corresponding to the type of data you want to store.
- If you want to specify the variable as a start variable, select the Initiation check box.
- Click to specify the Initiation options Initiation options control the display and behavior of the variable on the start form that is displayed when a workflow is started manually..
- Click Save.
For more information, see User-defined variable types and Initiation options.
The following table describes the variable types available in the Variables dialog box as well as their initiation options, which are available when you select Yes for Initiation. Initiation options control the display and behavior of the variable on the start form that is displayed when a workflow is started manually.
Variable type | Description |
Initiation Available |
Initiation options |
---|---|---|---|
Text |
Any text value. Underlying .NET data type: System.String. |
Yes |
|
Boolean |
Yes or No value. Underlying .NET data type: System.Boolean. |
Yes |
|
Date/Time |
Date and time value. Underlying .NET data type: System.DateTime. |
Yes |
|
GUID |
Globally unique identifier, often used to reference a list item in SharePoint. Underlying .NET data type: System.Guid. |
No |
(n/a) |
Number |
Numeric with a Decimal value. Underlying .NET data type: System.Double. |
Yes |
|
Integer |
Numeric without a decimal. Underlying .NET data type: System.Int32. |
No |
(n/a) |
Choice |
A value that requests a selection from a list of allowed values. The value selected by the workflow initiator is stored in the variable. Underlying .NET data type: System.String. |
Yes |
|
Person or Group |
A value that requests a selection from a user lookup. The item selected by the workflow initiator is stored in the variable. Underlying .NET data type: System.String. |
Yes |
|
Hyperlink |
A value that requests a hyperlink URL and description. Two text boxes are provided:
The values entered by the workflow initiator are stored in the variable. Underlying .NET data type: System.String. |
Yes |
|
Dictionary |
A container that holds a single logical unit of variables. For more information, see Dictionary variables. Underlying .NET data type: Microsoft.Activities.DynamicValue. |
No |
(n/a) |
Collection |
An index-based array of values, also known as an ordered list of values. For more information, see Collection variables. |
No |
(n/a) |
Edit an existing workflow variable
If you want, you can edit the name and Initiation setting of an existing workflow variable.
- On the designer toolbar, click Variables. The Variables dialog box appears.
-
Click the workflow variable you want to change and edit the name and initiation settings as needed.
Note: Variable type cannot be changed.
- Click Save to apply the changes. variable type cannot be changed.
Delete an existing workflow variable
If you want, you can delete an existing workflow variable.
- On the designer toolbar, click Variables. The Variables dialog box appears.
- On the row of the variable you want to delete, click and confirm the deletion.
- Click Save to apply the changes.
Configure a workflow variable as a start variable
You can configure variables to collect data when a workflow is manually started. These variables will be shown on a start form used to initiate the workflow and allows users to specify a value for the workflow variable before the workflow starts, basically passing values into the workflow before it starts.
Variables displayed on a start form are also known as the "start data" of the workflow and represent data that must be collected when the workflow is started.
Note: If the workflow starts automatically, then default values are used for start data.
To learn how to manually start a workflow, see Start a workflow manually.
Configure a variable to show on a workflow start form:
-
Open the required workflow. The workflow designer opens.
- On the toolbar, click Variables. The Variables window opens.
-
To edit an existing variable, click the required variable. The row becomes editable.
or
- Select the Initiation check box for the required variable.
- If you want to configure initiation options, click to open the Initiation options dialog box, make the changes and click OK. For more information about the fields, see User-defined variable types and Initiation options.
To create a variable, click New on the Variables window toolbar, enter a Name, and select the Type for the variable.
- Click Save to commit changes.
Workflow reference
A reference is used to construct content containing information specific to the list or library item and to the current instance of the workflow. You can insert a reference to configuration fields of actions in a workflow. References can be inserted only to configuration fields that accept references.
Do one of the following to add a reference to a workflow action:
- Click on the field that accept references and from the Insert Reference pane that appears on the right, double-click on a reference to select.
-
If the field is a drop-down list, select the lookup type and then, in the associated field, enter or select the reference.
- Click the lookup symbol to the right of the field and select the lookup type and then enter or select the reference. Displays a drop-down list. For more information, see Lookup.
For example, to insert the login name of the initiator (the person who initiated the workflow), in the Insert Reference pane, expand the section Workflow Context and then double-click the reference Initiator login name.
For example, to insert the current site URL, select Workflow Context and then select Current site URL.