Skip to main content

Assign

Assigns an array to a variable in the specified scope.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Array - The array to assign. Can be retrieved from the message scope or defined using JavaScript expressions.

Outputs

  • Array - The assigned array result, stored in the specified scope (Message, Flow, Global, or Custom).

How It Works

The Assign node assigns an array to a variable, making it available in the selected scope. When executed, the node:

  1. Receives an array through the Array input
  2. Validates that the input is a valid array
  3. Assigns the array to the output variable in the specified scope
  4. Handles thread-safe operations when assigning to Global or Flow scopes
  5. Returns an empty array if the input array has no elements

Requirements

  • Valid array as input (can be empty)

Error Handling

The node will return specific errors in the following cases:

  • Invalid array input
  • Scope-related access issues

Usage Examples

Example 1: Assign Array to Flow Variable

Assign a list of customer names to a flow variable for use throughout the automation:

  1. Create an array using JavaScript: ["John", "Mary", "David", "Sarah"]
  2. Set Array input to the created array
  3. Set Array output scope to "Flow" with name "customerNames"
  4. The array is now accessible throughout the flow as {{flow.customerNames}}

Example 2: Store Scraped Data in Global Scope

Store scraped product IDs globally for cross-flow access:

  1. Scrape product IDs from a website into an array
  2. Set Array input to the scraped data
  3. Set Array output scope to "Global" with name "productIDs"
  4. Access the array from any flow using {{global.productIDs}}

Example 3: Copy Array to Message Scope

Copy an array from one variable to another in the message scope:

  1. Set Array input to {{msg.sourceArray}}
  2. Set Array output scope to "Message" with name "destinationArray"
  3. Both arrays are now available in the message: {{msg.sourceArray}} and {{msg.destinationArray}}

Tips for Effective Use

  • Use Message scope for temporary data that only needs to exist within a single message flow
  • Use Flow scope for data that needs to persist across multiple nodes in the same flow
  • Use Global scope for data that needs to be shared across different flows
  • The Assign node is thread-safe when using Global or Flow scopes, preventing race conditions in parallel executions
  • Empty arrays are valid and will be assigned correctly
  • This node is useful for initializing arrays or copying arrays between different scopes

Common Use Cases

  • Initializing empty arrays for data collection
  • Copying arrays between different scopes
  • Converting temporary data (message scope) to persistent data (flow/global scope)
  • Preparing arrays for batch processing operations
  • Storing configuration or reference data that multiple flows need to access