Workflow variables can be used to:
- Capture information from surveys.
- Store and pass data between blocks in a workflow.
You can assign values to variables in a workflow or in a survey, and then use those values in workflow blocks.
Workflow variables are scoped to the workflow in which they are defined and cannot be accessed outside of the workflow.
About workflow variables
When defining a variable, you can select two primary categories of data types:
- Regular.
- Object.
Regular data types
These are used for simpler, often singular values. For instance:
- Currency amounts can be defined as a Decimal.
- Binary choices, such as "Yes" or "No", can be represented as a Checkbox.
Object data types
These are geared towards storing complex, multi-attribute records. For example, a user object may include attributes such as email, first name, last name, and date of birth.
Scenario
In an asset workflow, various alerts are sent to a user when the CPU usage of an EC2 instance exceeds a threshold.
Object variables can serve as bridges, allowing access to information from different objects even when this data isn't directly related to the primary object of the workflow.
Using the scenario above, we can introduce a user variable to the asset workflow. This permits access to a user record, and as the workflow progresses, specific values from this user record can be retrieved in each block.
Use dot notation to access the values within the user record, for example:
- For the Notify block, you could use {{WFVariables.[variablename].first_name}} and {{WFVariables.[variablename].last_name}} to get the user's name.
- For the Twilio block, you could use {{WFVariables.[variablename].phone}} to access the user’s phone number.
- For the Jira block, you could use {{WFVariables.[variablename].manager_email}} to notify the user’s manager.
Important
When creating an object data type, you do not need to change the Preferences section. This feature is only used when creating object fields for surveys. The exception is the Saved Search field, which can be used to modify what is displayed for objects in both surveys and workflows. To learn more about adding object fields for surveys, see Adding object fields for surveys.
Procedure
Complete the following steps:
- Navigate to Configuration > Workflows and create a workflow.
- When the workflow is in edit mode, select the Variables tab in the sidebar
.
- Click ADD VARIABLE.
- Specify the Variable name and the Data type.
Note
Unlike the workflow variable, which is a dynamic variable, you can also use static variables in workflows in the form of a global variable. Refer to Using global variables in workflows.
Comments
0 comments
Please sign in to leave a comment.