Skip to content

Set Variables

Overview

The Set Variables node allows you to set or update variables within your workflow dynamically. It reads a JSON dictionary of key-value pairs and adds them as variables to the current workflow context for use in subsequent nodes.


Purpose

Use this node to define or override variables dynamically during workflow execution, enabling flexible data configuration and runtime adjustments.


Inputs

InputTypeDescription
New VariablesJSON DictionaryA JSON object containing key-value pairs representing the variables to set. Example: {"MyVar":"Value","AnotherVar":"123"}

Outputs

Output Variable NameDescription
SetVariablesContains a dictionary of all variables that were set by this node, with their resulting values.

Execution Details

  1. Validation:

    • No specific required inputs are validated beyond general task validation.
    • Checks that User Inputs are present and contain the New Variables key.
  2. Variable Setting:

    • Reads the New Variables JSON input and converts it into a dictionary.
    • Iterates through each key-value pair and sets them as new user inputs (variables) in the workflow context.
  3. Output Handling:

    • Creates an output dictionary SetVariables containing the newly set variables and their values.
    • Returns with taskSuccess = true upon completion.
  4. Error Handling:

    • If New Variables input is missing or not a valid JSON object, the node fails with an error message.
    • Any unhandled exceptions will result in node failure with the exception message returned.

Example Use Cases

  • Defining variables dynamically based on logic earlier in the workflow.
  • Overwriting existing variables to update downstream processing.
  • Creating placeholder variables for use in script, API, or data operation nodes.

Notes

⚠️ Important:

  • The New Variables input must be a valid JSON object. Example:

    json
    {
      "Username": "admin",
      "Timeout": "30",
      "IsEnabled": "true"
    }

Tentech 2024