Set Variables Node

The Set Variable node is a fundamental component in workflow design, enabling the setting or updating variable values within the workflow. These variables can then be utilized by other nodes for dynamic data manipulation, enhancing the flexibility and functionality of the workflow.

Add the Set Variables Node to the Workflow

To add the Set variable node, follow the below steps:

  1. Add the Set Variables Node:

    1. Open your Nected workflow editor.

    2. Then click on the + icon and select the Set variable node from the list of available nodes.

Configure the Input Parameters:

In the Set Variable node, you define and assign values to variables that can later be used by other nodes in your workflow. Variables created here act as reusable data points that can be dynamically updated as the workflow progresses.

Inside the Input Params tab, you’ll see options to define variable types and assign values.

There are two ways to assign values:

  1. Enter a static value directly (for example, text, numbers, or dates).

  2. Use Input Attributes from triggers, previous nodes, or global variables — available through the token widget on the left side of the editor.

When you click into any value field, the Input Attributes panel automatically appears on the left. You can:

  • Search or expand groups like Trigger Attributes, Previous Node Attributes, Global Attributes, or System Attributes.

  • Drag and drop attributes directly into the input field to map dynamic data.

Each attribute will appear inside double curly braces ({{ }}), such as:

  • {{Trigger.sensor_id}}

  • {{SetVariable1.output.key_1}}

  • {{globalVar.leadScore}}

  • {{systemVar.NULL}}

Note: Only compatible data-type attributes appear in the panel for each variable type.


Add Variable

Use the Add Variable button to create a new key-value pair. Each variable can hold one of the supported data types listed below.

This structure allows you to not only initialize variables but also dynamically update or overwrite them later in the workflow with subsequent Set Variable nodes.

Supported Variable Types

Type
Description

Boolean

For true/false values. You can enter static values or use attributes from previous nodes.

String

For text data such as names or IDs. Static or dynamic attributes can be used.

Numeric

For integers or decimal values. You can use constants or attribute mappings.

Date

For dates in YYYY/MM/DD format (e.g., 2024/07/21). Static or dynamic mapping supported.

DateTime

For date-time values in RFC3339 format (e.g., 2024-08-07T12:46:00+05:30).

JSON

To input structured JSON data. For details, see the JSON Editor Documentation.

List

To input or update lists of values. For details, see the List Editor Documentation.

JS Code

To compute or assign values using JavaScript. For details, see the JavaScript Editor Documentation.

Formula

To compute values using formula expressions. For details, see the Formula Editor Documentation.

Each time you assign or update a variable, the Input Attributes panel ensures you have full visibility into the available data sources — making it easy to map the right values with drag-and-drop simplicity.

Test the Node

Test the node by running the workflow and verifying the values of the variables. Toggle between raw and pretty formats to ensure data integrity and correct formatting.

And then just click on "Save" to save the node.

Now if you want to change the timeout time, then you can do so using the timeout option in the settings tab. The timeout setting controls how long the node should wait for a response before timing out.

Updating Existing Variables(New):

There may be scenarios where you initially set a variable (e.g., discountPercentage) and later need to update it mid-flow based on new logic or data. This is now supported seamlessly with the enhanced Set Variable node.

To update the value of a previously set variable:

  1. Add a New Set Variable Node at the point in the workflow where the variable needs to be updated.

  2. In the Input Params tab, click on Reset Previous Variables.

  3. You’ll see a list of tokens representing all the variables set in earlier Set Variable nodes. Select the one you want to update.

  4. Enter the new value you want to assign to this variable. This can be a static value, a computed formula, or a token from any previous node.

  5. Save the node. The variable is now updated, and the updated value will be used in all downstream nodes referencing it.

This functionality supports updating a variable multiple times across the workflow, offering finer control and more dynamic logic construction without overwriting all previously declared variables.

Pass tokens among fields:

To maximize the efficiency of the SetVariable Node in your project, you can take advantage of its capability to pass previously stored values. This is achieved by using tokens within the same node, allowing you to seamlessly transfer data from one field to another. By employing this method, you ensure a smoother workflow, reduce errors, and enhance the adaptability of your system. This process not only streamlines information transfer but also contributes to a more organized code structure, ensuring that your variables are consistently up-to-date and easily accessible throughout the node's operations.

Use Set Variable Values in Other Nodes

Variables set in the Set Variables Node can be accessed in other child nodes using tokens. For example, if you set a variable userName in the Set Variables Node, you can use it in the next node like this {{SetVariable.output.key_4.username}}.

Conclusion

The Set Variable node empowers users to manage and manipulate data dynamically within workflows, offering support for a variety of variable types. By effectively utilizing the Set Variable node, users can create more versatile and efficient workflows to meet their specific requirements.

Last updated