- 3 Minutes to read
- Print
- DarkLight
- PDF
Variables in REST Actions
- 3 Minutes to read
- Print
- DarkLight
- PDF
The variables of an Action is actually the interface of the action with other rivers inside Rivery.
Variables can be used in Rest action and multi actions.
The variables screen can be opened by clicking on the variables button on the right side of the river. When opening the variables, a pop up with variables will be shown up:
Adding variables to an Action:
Click on add variable.
Enter the variable name and insert a value.
Click on is_private in order to keep that variable as private.
Variables types
The action variables have 3 types:
Action variable - Any variable that was added manually to the action variables.
Connection details - Any detail in the connection details of the current connection of the Action river. Any connection variable will have a prefix of “connection” .
Interval Params - The details of the selected time period of the Action river. Any variable of interval params will have a prefix of “time_range” .
Variables scopes
When building a Rest action, every variable of that Rest Action can be used anywhere in the Rest Action configurations. We call it the variables scope of the river.
When building a Multi-Action, it also has its own variables scope.
Any action that is being called in that Multi-Action, has its own variables scope, which is not the same variables scope of the Multi-action.
The only way to transfer variables between the scope of the multi-action to the scope of action inside it is via the input variables of the actions that are inside a multi-action:
In that picture, we can see 4 variables that are belonged to some action in a multi-action. If we won’t overwrite its values the action will run using its own values. If we’ll overwrite the values it will run using those values.
In Multi-action, it is possible to use its own variables only in the Input variables of the actions that are being called in that Multi-action (the picture above). In that way, we actually passing the values of the variables of the multi-action to the variables of the Rest actions inside it. It not possible to use the variables of the multi-action inside the actions that are being called inside it. When editing an action inside the screen of a multi-action, it is possible to use only the variables of this opened action, because it has its own variables scope. Note: Rivery's Global Variables are NOT visible within the scope of action rivers unless they are explicitly passed in.
Use the variables in Actions
Use variables in a Rest Action
The variables of the Action can be used in any input of the action by entering {}.
After entering {}, a list with all the variables will be shown up, then Select any variable to add.
Use variables in a Multi-Action
The multi-action is actually composed of multiple predefined Rest Actions.
The multi-action variables have the same types as the Variables types of an Action, in addition to another type, unique to the multi-action - the output variables. The output variables are all the variables that are being returned from actions inside that multi-action.
The variables can be used only in the input variables of the actions that are being run inside the multi-action.
The variables of the Multi-Action can be used in any input variable of its own actions by entering {} . After entering {} , a list with all the variables will be shown up, then Select any variable to add.
Click here to read about how to use variables inside a multi-action.
- If time period selected, the variables list when entering {} will include also additional time parts of the selected dates (such as “time_range.start_date.day” etc.)
Use variables in a Logic River
One of the most popular usages in actions is passing a rest API call relevant data from your table.
First, create a logic river.
Create a new step that will load your relevant data into a variable (Multiple values variable if needed)
The next step can be your action:
create a new rest action river and add it a new variable - it will be the input variable for this action.
Use this variable in this action (you can use it for example in the request body or in the request params ).
Back to our logic river: In the action step (click on refresh action button if you cannot see the input variables) click on input variables and add the variable that you created in the last step.
In this example, the variable will be sent as an array of arrays (every row from the query).