# 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.

{% embed url="<https://youtu.be/KhgmAqVt7dE>" %}

### 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.\
      ![](https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FIWOOYZEzXw2N4EAcYgjS%2Fset_var_1.png?alt=media\&token=f0cdb214-9685-4db7-8231-9753fb740966)

### **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**.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FkfRrZaZSJ813xEjFdOr5%2Fimage.png?alt=media&#x26;token=78601354-f0f2-4c62-988f-af702d487489" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FI8qwlFgTTQsj0fD4Ds7B%2Fimage.png?alt=media&#x26;token=af02f1ca-07e6-4dc6-86f3-b69909c1bd6b" alt=""><figcaption></figcaption></figure>

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](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419).                      |
| **List**     | To input or update lists of values. For details, see the [List Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419).                 |
| **JS Code**  | To compute or assign values using JavaScript. For details, see the [JavaScript Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419). |
| **Formula**  | To compute values using formula expressions. For details, see the [Formula Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419).     |

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**&#x20;

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.<br>

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FvJnqpDb5QcHTWUvzFomg%2FExport-1722935201454.gif?alt=media&#x26;token=9e623784-66fa-4cec-9286-fed9406561c0" alt=""><figcaption></figcaption></figure>

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

{% hint style="info" %}
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.
{% endhint %}

### 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.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FmuhvjYKivA9GwNEIXgnJ%2Fimage.png?alt=media&#x26;token=303db327-164f-412a-9650-3f088cd8ee16" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FAPuwtVPwG3XlUg2cIGhW%2FExport-1730193039745.gif?alt=media&#x26;token=2ddb8c92-9ec3-458f-91c6-fb6962fa25ac" alt=""><figcaption></figcaption></figure>

### 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}}`.&#x20;

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FPhKfW6A54E9VNb8h96CX%2Fimage.png?alt=media&#x26;token=840f7454-d534-42e4-b8be-cae4a7e01019" alt=""><figcaption></figcaption></figure>

### 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nected.ai/nected-docs/workflow/add-node/control-nodes/set-variables-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
