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. This is how data is transferred between actions in a process.
For example, you can use a Call API action to retrieve a list of emails and store them in a process variable called clientEmails. Later in the process, in a Send Email action, you can reference the clientEmails process variable and use the data to send emails to those email addresses.
A process variable has the following properties:
- Name: name of the variable
- Data Type: this can be primitive or custom
- Default Value: the default value that will be used for that variable 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 is expected to be set after running the process
Go to the Process Designer and create a new process or open an existing one.
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: choose the data type of your variable
- 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: choose whether the variable will be treated like a list or not
- 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. 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 CTRL + I or by clicking on the + sign. Both actions will open the Process Variables selector from where you can select the process variable you want to use.
For each Process Variable you can see:
- name
- type (color-coded tags)
- attributes (for custom data types)
- list tag
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:
Example: customerAddress is a process variable sent as a query parameter in the Call API action:
Example: cityName and feelsLike are process variables in Email Subject.