Skip to main content

Set Value

Controlled node

Overview

The Set Value node modifies an object or list by setting a value at a specific path. It supports nested properties using dot notation (e.g., user.profile.name) and array indices (e.g., users.0 or 0). The node mutates the input object in-place and outputs the modified object.

This is useful for updating specific fields in complex data structures, appending to arrays, or modifying nested dictionary values within a workflow.

In-place mutation

This node modifies the input object directly. The output newObject is the same object reference as the input, with the value updated at the specified path.

Inputs

InputTypeDescriptionDefault
RunEventFires when the node starts running-
ObjectDataThe object, dictionary, or list to modify-
PathTextThe path to the property to set. Use dot notation for nested objects (e.g., user.name) or numbers for array indices (e.g., 0 or items.2)-
ValueDataThe value to set at the specified path-

Outputs

OutputTypeDescription
DoneEventFires when the node has finished
New ObjectDataThe modified object (same reference as input)

Runtime Behavior and Defaults

Path Resolution

The node parses the Path input to navigate the object structure:

  • Dot notation: user.profile.name accesses object.user.profile.name
  • Array indices: users.0 accesses the first element of object.users
  • Mixed: data.0.value accesses object.data[0].value

Array Operations

  • Existing indices: Setting users.1 updates the second element
  • Appending: Setting users.2 on an array of length 2 appends a new element at index 2
  • Out of bounds: Throws an error if the index is negative or exceeds the array length (for setting existing indices)

Error Conditions

The node will throw an error if:

  • The Path is empty or invalid
  • An array index is out of range (negative or greater than length when accessing)
  • A property key doesn't exist in a non-array object (when traversing intermediate paths)

Example Usage

Setting a nested property:

// Input Object: { user: { name: "John", age: 30 } }
// Path: "user.name"
// Value: "Jane"
// Output: { user: { name: "Jane", age: 30 } }

Updating an array element:

// Input Object: { items: ["apple", "banana", "cherry"] }
// Path: "items.1"
// Value: "blueberry"
// Output: { items: ["apple", "blueberry", "cherry"] }

Appending to an array:

// Input Object: { tags: ["urgent", "review"] }
// Path: "tags.2"
// Value: "approved"
// Output: { tags: ["urgent", "review", "approved"] }

Setting a top-level array element:

// Input Object: ["red", "green", "blue"]
// Path: "0"
// Value: "yellow"
// Output: ["yellow", "green", "blue"]