Back to Integrations
Logic

Smart Iterator

The Smart Iterator acts as a bridge between massive arrays of data and a Sub-Workflow. It elegantly solves array handling by iterating through items and dispatching them to an isolated workflow either one-by-one or via ultra-fast concurrent Goroutines, then stitches the results perfectly back together.

Smart Iterator
Core / Logic

What can you do with Smart Iterator?

Parallel Fan-Out Execution

Select 'Parallel' mode and configure a Concurrency Limit. nLink will instantly spawn multiple lightweight background threads to process your array items simultaneously, boosting execution speeds by 10x to 100x.

Data Race Free Merging

Even when processing in parallel where items finish out-of-order, the Iterator natively preserves the strict chronological index of the results. Your output array order is perfectly synchronized with your input array.

Graceful Context Cancellation

If 'Stop On First Error' is enabled, a single item failure will broadcast an instant cancel signal to all other concurrent workers. This immediately halts pending executions, preventing API quotas from being burned uselessly.

Detailed Usage & Configuration

The Smart Iterator is the ultimate tool for crunching massive datasets iteratively utilizing nLink's Sub-Workflow architecture.

1. Configuration Modes

  • Workflow Target: Choose the explicit Sub-Workflow you want executed for every item in your payload array.
  • Sequential Mode: Safely runs Item 1, waits for it to finish, then runs Item 2. Best for interacting with strict third-party APIs that heavily rate-limit sequential calls.
  • Parallel Mode: Defines a hard Concurrency Limit (e.g. 50). The Engine blasts the Sub-Workflow asynchronously across 50 simultaneous threads, maximizing internal CPU efficiency.

2. Automatic Result Flattening

Because Sub-Workflows inherently return an array of outputs, the Smart Iterator intelligently intercepts the returning data arrays and flattens them into a single, clean dimensional array. For example, [[{a:1}], [{b:2}]] becomes smoothly aggregated into [{a:1}, {b:2}] natively, eliminating the need to use a complex Item List Aggregation node afterwards.

⚡ Error Handling Note: If you toggle Continue On Error, the Iterator will not crash the workflow if a Sub-Workflow fails. Instead, it captures the error string as a clean JSON object {"error": "...", "itemIndex": idx} and places it into the results array, allowing your downstream nodes to gracefully branch and isolate failed rows.