Skip to main content

setVariable

Sets a global variable. Global variables are stored in the memory and only persist until the application is fully closed, at which point they are removed.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"value" (required)String,ObjectThe value of the variable.null
"variable" (required)StringThe name of the variable.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example 1: Create a global variable with assigned static value.

Goal: Create a global variable named "favoritePet" and assing it the value "cat".

Variable and value have to be assigned within the params object of the action.

{
"type": "setVariable",
"params": {
"variable": "favoritePet",
"value": "cat"
}
}

Result:

The global variable "favoritePet" has been set with the value "cat".

Example 2: Create a global variable with assigned dynamic value.

Goal: Create a global variable named "favoriteColor" and assign it a dynamic value.

Variable and value have to be assigned within the params object of the action.

{
"type": "setVariable",
"params": {
"variable": "favoriteColor",
"value": {
"context": "form",
"field": "pickedColor"
}
}
}

Result:

The global variable "favoriteColor" has been set with the dynamic value of the "pickedColor" form.