Working with Process Variables
A process variable acts as a placeholder for data that can be accessed throughout the lifecycle of a process. When the process is running, it passes dynamic data between actions. It is how data is transferred between actions in a process.
For example, in an action that calls an API, you can store the data in a process variable called <%clientsEmails%>. Later in the process, in an action that sends emails, you can reference the <%clientsEmails%> process variable and use the data to send emails to those clients' email addresses.
A process variable has the following properties:
- Name: the name of the variable
- Data type: can be any primitive data type or data model
- Default value: the default process value that will be used at runtime if no other value is set
- Single value or list flag: a variable can be treated as a single value (default behavior) or a list of values
- Input flag: the variable value is expected to be set when starting the process
- Output flag: the variable value will be part the/part of the output of a process
Go to the Process Designers section and open a new or an existing process.
Step 1: On the process page, click on the Process Variables icon (x).
Step 2: Click on the Create variable button.
Step 3: Process variable configuration
- Name*: you can set the name of the variable which you want to use when configuring an action;
- Type: set the data type of your variable; this can be either a primitive like string, integer, Boolean or other, or it can be a custom type that you defined in the data model designer;
- Default value: you can specify a default value for your variable; at runtime, if no other value is set for this variable at runtime, the default value will be used, otherwise the default value will be replaced by runtime values.
- Single list/Value: mark it as a list if the process variable will have more than 1 value; e.g. we can add several email addresses as default values;
- Set as Input or Output: you can mark a variable as input if you know that data is needed in order for the process to run successfully; or you can mark it as output if you expect that data to be the result of the process, which will allow you to transfer that data to the client application. Default behavior: not marked as input/output, it will act as a process variable within the process, passing dynamic data between actions.
Step 4: Press Create Variable.
When configuring an action you can insert process variables in inputs by pressing "#" or by clicking on "Add variable". Both will generate the Process Variables selector from where you can select the process variable you want to use.
For each Process Variable you can see:
- type (color-coded tags)
- attributes (for custom data types)
- list tag
Each variable will have a color-coded tag to easily map the variable to its data type::
Process Variables can be inserted into the process flow for different purposes:
1. Input process variable
2. Output process variable
3. Process variable used within the process to pass dynamic data between actions
They can be easily identified in the Process Variables list:
Whenever you use process variables in configuration, it is easy to visually differentiate values from process variables. Process variables are in a colored pill, unlike values:
Example1: <%customerAddress%> is a process variable sent as QueryParams in the Call API action:
Example2: <%cityName> and <%feelsLike> are process variables in Email Subject.