Taking a look at what you can do with the various variables within the action builder.
After reading this article you'll know:
-
What a variable is
-
The various types of variables
-
The scope in which variables are & can be used
What are variables
You can think of variables as storage for values, which you can reference by name. A variable can be assigned a different value at any time, making it usable in dynamic situations. For example, a coder can create a formula like a + b = c
, using the 3 variables a
, b
and c
. By assigning different values to the variables, this formula can be reused over and over and produce different outcomes.
A variable consists of a name and a type. The variable type indicates which kind of value this variable contains. For example a piece of text or a number.
Variable types
In the action builder, the following 4 variable types are available while building an action:
-
Action variables
-
Input variables
-
Step variables
-
Output variables
We'll go over each variable below.
Action variables
An action variable can be created and initialized with a value by clicking on the start
step in the action flow.
By clicking on + Add
you can add new variables to your action.
In the modal screen which is displayed to the user, the builder can select the variable kind, specify the name of the variable and initialize it with a value.
Editing the variable can be done by clicking on the variable in the list
Input variables
Input variables can be created by clicking on the start
step. They cannot be initialized with a value in the action itself. Input variables are created in order to receive their value from the user of the action, which can for example be the page builder which sends values from input forms to the action as input variables.
To add new input variables to your action go the start step
and click on the + Add
button.
In the pop-up which is displayed to you, you can select the variable kind and specify the name of the variable.
Editing the variable can be done by clicking on the variable in the list.
Step variables
Step variables can be created in the configuration of a step itself.
You can add a new step variable by clicking on the + Add
button when you have a step selected.
In the pop-up which is displayed to you, you can select the variable kind and specify the name of the variable.
Editing the variable can be done by clicking on the variable in the list.
Output variable
In the Finish step of the action, you can choose a variable (which was created within the action) that will be returned to the end-user as a result of the action.
The scope of variables
Variables are only available for use inside the region of the action they are created in. This is called the scope.
Variables like the action variable and the input variable are available within the scope of the whole action. Everywhere in the action, these variables can be read or changed.
Step variables are created in the scope of the step. Only in the step self, these variables can be used. A step variable, created in the ‘Create record’ step, can only be used in the Create record step, not in any subsequent steps, and not in any preceding steps. There are two step types that have a slightly different scope rule.
Steps with their own variables
Steps of this type can be identified by having a circle-shaped icon.
An example is the loop step. Variables defined in the loop step, are available to all steps configured in the context of the loop. They are not available anymore when the loop is finished.
For example; the variable “loop_iterator” created in the loop step above is available in the create record and log message step within the loop. But outside of the loop flow; this variable can not be used anymore.
Read more about the loop step here.
Variable types
The following variable types are available to any user while creating their action.
Text |
|
description |
stores a piece of text with a maximum of 4GiB of characters |
example |
“John Smith” |
availability |
action, input, step, output |
Number |
|
description |
stores integers without decimals |
example |
123 or -123 |
availability |
action, input, step, output |
Checkbox |
|
description |
stores a value indicating a binary state: true or false |
example |
true |
availability |
action, input, step, output |
JSON (only input) |
|
description |
stores a piece of text structure as a JSON object. see JSON |
example |
{company:"Betty Blocks", house_number:7, city:"Alkmaar"}; |
availability |
action, input, step, output |
Object (only input) |
|
description |
stores an object |
example |
- |
availability |
action, input, step, output |
Array (only input) |
|
description |
stores one or multiple text or number variables |
example |
[1,2,3] or [“up”, “down”, “left”, “right”] |
availability |
action, input, step, output |
Record (action var, step) |
|
description |
stores a database entry retrieved from a model |
example |
- |
availability |
action, input, step, output |
Collection (action var, step) |
|
description |
stores one or multiple record variables |
example |
- |
availability |
action, input, step, output |
All variable types can be used as output variables in the finish step.