Logic action Logic

Iterates over an array and executes child nodes sequentially for each item. Supports nesting up to 10 levels. Inner loop: $item/$index, outer loop: $parent_item/$parent_index, any ancestor: $for.{nodeID}.item/$for.{nodeID}.index. Max 100 iterations per loop. Runtime budget: 10,000 total nodes. Loop body nodes go in loopBody field. Post-loop nodes go in children field (execute after all iterations finish).

At a Glance

FieldValue
Action IDfor-each
CategoryLogic
ConnectorNot required
Requires gasNo
Funds movementNone declared
Tagslogic, loop, iteration, for-each, control-flow

Payload Schema

FieldTypeRequiredDescription
arrayarrayYesArray to iterate over (can be template variable like {{node.result.items}})

Result Schema

FieldTypeRequiredDescription
iterationsarrayYesArray of iteration results
iterationCountintegerYesTotal number of iterations executed
lastAdvancedIterationintegerNoIndex of the last iteration that was advanced (iterationCount - 1)
statusstringYesLoop execution status

Examples

json
{ "type": "for-each", "payload": { "array": [] }, "children": []}

Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.

Ask a question... ⌘I