Workflow Variables
Variables are used to store data which can then be used within the workflow for decision-making, informational display, or use within a script. Variables by nature are changeable, and are a core concept of all programming languages, as well as “code-less” configuration.
Throughout the lifecycle of a workflow, the values stored in the variable can be set, modified, queried, and used in scripts and other workflow objects.
Use
Data types of variables
The data type of a variable refers to the type of data it can store.
Dev tip
To avoid data mismatch and workflow logic issues, it is best practice to match the variable type with the value. eg. Use date variable to store date information etc. Don’t store a number in a string field etc.Workflow variables are available in the following data types:
- String: A string variable is used for storing text values. String variables can contain multi-line text
- Number: A number variable is useful for counting and storing number values. Values can either be positive or negative whole numbers
- Date and time: A date/time variable that is used to store both date and time values
- Date only: A date variable that is used to store the date component only (no time)
- Time only: A time variable is used to store a time component only (no date)
- Entity: A dual-state variable that stores data about an entity eg. Client, Asset or Site
Local vs Public variables
By default, all variables are created as local variables which means they can only be used in the current worfklow canvas. When a Job, or Job Template also contains an OnCreate workflow, it is possible to widen the scope of the variable to “Public” so that a variable can be used in all workflow designers.
Creating Variables
To create a variable, ensure that the Variables dockable panel is displayed. This is located on the right of the workflow designer. This panel can be “pinned” to stay open and visible.
- Click Add to create a new variable.
- Select from either a number, or a string type variable.
- Give the variable a meaningful name
Renaming and Deleting Variables
Once a variable has been created, it can be renamed, or deleted. Use the options on the dockable variables panel to perform these functions.
Assigning values to variables
Once a variable has been created, you can assign a value to it by a number of different ways, including:
- Explicitly setting the variable to a specific value when it is created, or via a workflow step.
- Prompting the user to input a value
- Running a script (SQL or Powershell) to set the value
- Set the variable from an existing value in a Control Set field
Working with Variables
When a variable is clicked on in the workflow panel, all workflow objects that use that variable will highlight in a different colour. This makes it easy to see which objects are using that variable. Conversely, clicking on a workflow object that contains a variable will highlight the variable in the workflow panel.
See Also
Set a variable based on user input
Database scripting with SQL that include variables
Branch workflow based on the value of a variable
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.