Skip to main content

Push

Adds an element to the end of an array.

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 add an element to. If null, a new empty array will be created.
  • Value - The element to add to the end of the array. Can be any data type.

Outputs

  • Array - The modified array with the new element added to the end.

How It Works

The Push node adds a new element to the end of an array. When executed, the node:

  1. Receives an array through the Array input (or creates a new empty array if null)
  2. Receives a value through the Value input
  3. Appends the value to the end of the array
  4. Returns the modified array through the Array output
  5. Handles thread-safe operations when working with Global or Flow scope variables

Requirements

  • Value input can be any data type: string, number, object, array, or boolean
  • If the array is null, a new empty array is automatically created

Error Handling

This node is very forgiving and handles edge cases gracefully:

  • If the array is null, it creates a new empty array automatically
  • Any value type is accepted and added to the array
  • No specific error conditions exist for this node

Usage Examples

Example 1: Collect Scraped Data

Build a list of scraped products:

  1. Initialize empty array: {{flow.products}} = []
  2. For each product on page: a. Scrape product details → {{msg.product}} b. Push {{msg.product}} to {{flow.products}} c. Updated array stored back to {{flow.products}}
  3. Result: All products collected in {{flow.products}}

Example 2: Build Task Queue

Create a queue of tasks to process:

  1. Array: {{flow.taskQueue}} = ["Task1", "Task2"]
  2. Value: "Task3"
  3. Push → Result: ["Task1", "Task2", "Task3"]
  4. New task added to end of queue

Example 3: Accumulate Search Results

Collect results from multiple searches:

  1. Initialize: {{flow.allResults}} = []
  2. Perform search 1 → get result object
  3. Push result to {{flow.allResults}}
  4. Perform search 2 → get result object
  5. Push result to {{flow.allResults}}
  6. Continue for all searches
  7. Result: Array containing all search results

Example 4: Build Dynamic List

Create a list based on conditions:

  1. Initialize: {{msg.filteredItems}} = []
  2. Loop through source data
  3. For each item: a. Check condition (e.g., price < 100) b. If condition is true, Push item to {{msg.filteredItems}}
  4. Result: Array containing only items that meet criteria

Example 5: Log Activity History

Track user actions in sequence:

  1. Initialize: {{flow.activityLog}} = []
  2. When user performs action: a. Create log entry: {"action": "login", "time": "2024-01-15 10:30"} b. Push entry to {{flow.activityLog}}
  3. Each action is appended to the history
  4. Result: Chronological log of all activities

Example 6: Aggregate Data from Multiple Sources

Combine data from different sources:

  1. Initialize: {{flow.aggregatedData}} = []
  2. Query database 1 → get records
  3. For each record, Push to {{flow.aggregatedData}}
  4. Query database 2 → get records
  5. For each record, Push to {{flow.aggregatedData}}
  6. Result: Combined data from all sources

Tips for Effective Use

  • Auto-initialization: If array is null, Push creates a new empty array automatically
  • Any value type: Push accepts strings, numbers, objects, arrays, and booleans
  • Thread-safe: Safe for Global and Flow scopes in parallel executions
  • Use in loops to collect data iteratively
  • Combine with conditional logic to build filtered lists
  • More efficient than Concatenate for adding single elements
  • Store the result back to the original variable to maintain state
  • Perfect for building lists dynamically during automation
  • Use with Pop to implement stack (LIFO) behavior
  • Use with Shift to implement queue (FIFO) behavior

Common Use Cases

  • Web scraping data collection (adding each scraped item)
  • Building filtered lists based on conditions
  • Creating task queues for sequential processing
  • Accumulating results from multiple API calls
  • Logging activities and events chronologically
  • Building dynamic dropdown options
  • Collecting form inputs across multiple steps
  • Aggregating data from multiple sources
  • Creating lists for batch processing
  • Implementing queue and stack data structures

Difference Between Push and Concatenate

OperationPushConcatenate
AddsSingle elementEntire array
PositionEnd of arrayEnd of array
Input typeAny valueArray only
Use caseAdding one item at a timeMerging two arrays
ExampleAdd one productMerge two product lists

Integration Examples

Example: Web Scraping Loop

1. Initialize: {{flow.products}} = []
2. For each page:
a. Navigate to page
b. Get product elements
c. For each product element:
- Extract product data → {{msg.productData}}
- Push {{msg.productData}} to {{flow.products}}
d. Go to next page
3. Result: {{flow.products}} contains all products from all pages

Example: Conditional Data Collection

1. Initialize: {{flow.validItems}} = []
2. Get source data → {{msg.allItems}}
3. For each item in {{msg.allItems}}:
a. Check validation criteria
b. If valid:
- Push item to {{flow.validItems}}
c. If invalid:
- Skip item or log error
4. Result: {{flow.validItems}} contains only valid items

Example: Multi-Source Data Aggregation

1. Initialize: {{flow.combinedData}} = []
2. Source 1:
a. Query API 1 → get results
b. For each result, Push to {{flow.combinedData}}
3. Source 2:
a. Query API 2 → get results
b. For each result, Push to {{flow.combinedData}}
4. Source 3:
a. Read from database → get records
b. For each record, Push to {{flow.combinedData}}
5. Result: {{flow.combinedData}} contains data from all sources

Example: Stack Implementation (LIFO)

Push (add to stack):
1. Get current stack: {{flow.stack}}
2. Push new value to stack
3. Update {{flow.stack}}

Pop (remove from stack):
1. Get current stack: {{flow.stack}}
2. Pop → get last value
3. Process the value
4. Update {{flow.stack}}

Result: Last-In-First-Out behavior

Example: Queue Implementation (FIFO)

Enqueue (add to queue):
1. Get current queue: {{flow.queue}}
2. Push new value to queue
3. Update {{flow.queue}}

Dequeue (remove from queue):
1. Get current queue: {{flow.queue}}
2. Shift → get first value
3. Process the value
4. Update {{flow.queue}}

Result: First-In-First-Out behavior