About workflow variables
This topic describes use of workflow variables.
Workflows retrieve data from a data source at run time. Workflow variables provide 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.
Storing values as metadata for the item attached to the workflow is always not appropriate or feasible. Workflow variables provide the means and flexibility to handle these scenarios. Some examples of when workflow variables are useful:
- A conditional action in the workflow that requires a combination of values already in the system. For example, these values can be set using the actions Math operation and Build string.
-
A need to avoid manual updates to hard-coded values, as in workflows developed in a development environment for deployment to testing and then subsequently deployed to production environments. Workflow variables can load values from other lists using lookups (see Use lookups) such as environment-specific URLs for email messages. The values can be sourced at runtime from a configuration list within each environment using the action Set a variable.
-
New list items (created by the action Create item). 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. For example, a new report requires that a meeting is organized, but during the workflow an administrator has rejected the report. Therefore the calendar event needs to be deleted.
Workflow actions that use workflow variables are restricted to specific variable data types. A few examples follow.
- The action Math operation is restricted to variables of the type Number.
- The action Create item is restricted to variables of the type List Item ID.
- The action Set a condition, when used to compare created dates, is restricted to variables of the type Date and Time.