Iterator
Description
Section titled “Description”The Iterator module receives a data array and executes the following workflow nodes for each element of the array in parallel. Each element is processed independently with its own metadata (_meta_) that includes the current index, total number of elements, and a unique execution identifier. If the input data is not an array but is an object with numeric keys, it is automatically converted to an array. It is the fundamental node for batch processing in workflows and must be combined with a merge node (mergeResults, mergeIterator) to recombine the results.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| expression | text | No | Expression that returns the array to iterate over. By default, data is used directly. |
Output
Section titled “Output”{ "_iterating": true, "batch": [ { "_meta_": { "workflowRunId": "1679561234567", "totalChunks": 3, "currentChunk": 0, "currentIndex": 0 }, "data": { "nombre": "Item 1" }, "nextModule": "siguiente_modulo" }, { "_meta_": { "workflowRunId": "1679561234567", "totalChunks": 3, "currentChunk": 1, "currentIndex": 1 }, "data": { "nombre": "Item 2" }, "nextModule": "siguiente_modulo" } ], "data": { "summary": [ { "poscurrent": 0, "status": "pending", "record": { "nombre": "Item 1" } }, { "poscurrent": 1, "status": "pending", "record": { "nombre": "Item 2" } } ], "workflowRunId": "1679561234567" }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”{ "label": "Iterator", "expression": ""}- Input data must be an array. If an object with numeric keys is received (e.g.:
{0: "a", 1: "b"}), it is automatically converted to an array. - If the data is not an array or a convertible object, an error is returned.
- Each element of the array is passed individually as
datato the next node. - The
workflowRunIdis generated from the current timestamp (Date.now()). - Returns
_iterating: truewith abatcharray so the engine executes each element in parallel. - The batch’s
nextModuleisnullat the root level to prevent automatic continuation; each batch element contains its ownnextModule. - The
expressionfield allows specifying a custom expression to obtain the array to iterate over, althoughdatais used by default.
Related Nodes
Section titled “Related Nodes”- MergeResults - recombines the iteration results
- MergeIterator - simplified iteration merge
- Repeater - generates N repetitions instead of iterating an array
- Merge - basic chunk merge