12.03 Using SetVariables node and the add operator
As an example of using the SetVariables node, let's create a scenario where the outcome will be a variable containing an array.
To make the scenario work successfully, you need to add 4 node:
- (1) A Trigger on Run once node to initiate a single scenario run immediately after clicking the Run Once button;
- (2) An Iterator node , containing a sequence of values in the form of [1, 2, 3, 4, 5];
- (3) A SetVariables node that assembles a variable, which is an array;
When configuring the SetVariables node, it's important to correctly specify the variable assembly algorithm using the "add" operator:
- The operand of the expression will automatically be the specified variable.
- The value of the expression should be selected as the value of the Iterator node.
tip
With each iteration, the value of the variable specified in the SetVariables node is new and equal to an element of the array.
- (4) A Webhook Response node that returns the specified variable.
The outcome of the scenario will be an array of values: