Set Variable

Updated at:
Copy as MD

The Set Variable node modifies the value of an existing global or local variable. Use this node to set a variable's value as part of the intermediate logic within the current service. The node then outputs the updated value.

Limitations

When using a global variable, you can only set its value serially across one or more services. Setting the same global variable in parallel is not supported.

For example, a service flow must complete its operation on a global variable before another service flow can set the value of that same variable.

Prerequisites

A global or local variable must exist. For more information, see Add a variable.

Node configuration

In the business logic editor, drag the Set Variable node from the Node > Data list to the canvas.

Parameter Description
Node Name The name of the node. The name can contain letters, digits, and underscores (_). The name cannot exceed 30 characters.
Set Variables Add the variables to modify.
Note You can modify up to 20 variables simultaneously.

In the configuration panel on the right, click +Variable to set the variables.

  1. Select the variable you want to set.
  2. Set the data source type and value for the variable.

    Available types:

    • Fixed value: Select a static data type, such as number, string, boolean, time, array, or struct.
    • From node: Select previous node (payload).
    • Variable: Select another existing variable.
    Note The data format of the new value must match that of the variable.
  3. Click OK.

Node output

The node outputs the final values of the variables.

Note The output parameter fields of the Set Variable node are the same as those of the previous node.
"log":{
        "nodeId":"node_***"
        "nodeName":"Set Variable"
        "nodeType":"store"
        "nodeInput":{
        "calcul_result":9
        }
        "variables":{
                "count":9
                }
        "duration":"0ms"
        "nodeOutput":{
                "calcul_result":9
                }
        "debugLog":[
                0:"{ dataSource: 'payload', dataSourceType: 'payload', staticDataType: 'num', variableName: 'count', propertyType: 'payload', property: 'calcul_result', value: 9 }"
                ]
}

Usage

Use this node with a global variable or a local variable. For detailed examples, see Use variable examples.