Workflows retrieve data from a data source at run time, workflow variables provides the ability to store data somewhere in order to use it in the conditions and actions within the workflow. Different types of data can be stored in a workflow variable. A workflow variable can also be used to get data from users on workflow start.
Some examples of when workflow variables are useful:
- The workflow requires a value for conditional actions which is a combination of values that exist already in the system. For example, these values can be set using the Math operation or Build Dynamic String actions.
- Workflows developed in a development environment for deployment to testing and then subsequently deployed to production environments. To avoid using hard coded values in the workflow that must be manually updated during deployment, workflow variables can be used to load values from other lists via Using lookups. e.g. a URL to be used in an email may be different for each environment, this can be sourced at runtime from a configuration list within each environment using the Set a variable action.
- A workflow may require the creation of another list item that will need to be queried later using a lookup or deleted automatically depending on further logic in a workflow. E.g. a new report requires that a meeting is organised, but during the workflow an administrator has rejected the report. Therefore the calendar event needs to be deleted.
It is not always appropriate or possible to store some of these values as meta data of the item attached to the workflow. To provide the means and flexibility to handle these kinds of scenarios Nintex Workflow provides workflow variables.
Managing Workflow Variables
To create or delete a variable attached to a workflow:
- In the Nintex Workflow Designer Ribbon, click on Workflow Settings.
- In the Workflow Settings dialog, within the Ribbon, click on Variables.
Alternatively:
- In the Nintex Workflow Designer, below the Workflow Settings in the Ribbon, expand the available options by clicking .
- Click on Variables.
- The Workflow Variables dialog will be displayed listing all of the current variables that are configured with their type and if the workflow variable is used at the start of the workflow as indicated in the Show on start form column.
To create a new workflow variable:
- In the Workflow Variables Ribbon, click on New.
- The Create Workflow Variable dialog will be displayed.
- Name: The name of the workflow variable.
- Type: The data type of the workflow variable.
- Default value: The default value given to the workflow variable when the variable is used within the workflow.
- Show on start form: Checking this option will allow users to specify a value for the workflow variable when the workflow is first started. Note: Start Variables (Start data) will only appear if the workflow is set to start manually, if the workflow starts automatically, the start variables fields will not appear and if default values are set, they will be used for the variables.
- Required: Only available when a variable has the Show on start form option checked. Checking this option will ensure users enter a value into the workflow variable on start of the workflow before a workflow can start.
Note: Not all Types can be used to get value from a user on the start of the workflow. The Show on start form checkbox will be greyed out if the type is not supported.
To modify an existing workflow variable:
- In the Workflow Variables dialog, select the workflow variable in the list.
- In the Ribbon, click on Modify.
- In the Modify Workflow Variable dialog, make the changes. Changes to the type cannot be made.
- When all changes have been made, click Save.
To delete an existing workflow variable:
- In the Workflow Variables dialog, select the workflow variable in the list.
- In the Ribbon, click on Delete.
Note: Workflow actions that use workflow variables are restricted to specific variable data types. For example:
- For Math operation you will only be able use number variables;
- When creating a new item only a List Item ID variable can be used to store the ID of the new item;
- A Set a condition action that is comparing the created date can only use a DateTime variable.