Input & Output
Body and done port behaviour, per-iteration data injection, and data accumulation patterns.
Output Ports
| Port | When Triggered | Description |
|---|---|---|
body |
Once per array element, before processing that element | Fires for each item in the configured array. The execution context includes current_index and current_item for the current iteration. Connect the nodes that should process each item to this port. |
done |
After all iterations complete OR after a Break node exits the loop | Fires exactly once after the loop finishes. Receives the full execution context with all accumulated variable changes made during the loop body executions. Connect post-loop processing nodes to this port. |
Output Data
| Field | Available On | Type | Description |
|---|---|---|---|
current_index |
body port (each iteration) | integer | Zero-based index of the current array element. First item = 0. |
current_item |
body port (each iteration) | any | The actual value of the current array element. Object, string, number, or any valid JSON value. |
loop_total_items |
body port and done port | integer | The total number of items in the array at the time iteration began. Constant across all iterations. |
loop_completed_normally |
done port only | boolean | True if the loop completed all iterations. False if a Break node caused early exit. |
| All accumulated variables | done port | various | All workflow variables modified during loop body executions are available with their final values after the loop completes. |
Data Flow Example
// === Pre-loop variables ===
{
"lineItems": [
{ "sku": "PRD-001", "qty": 2, "price": 15.00 },
{ "sku": "PRD-002", "qty": 1, "price": 40.00 },
{ "sku": "PRD-003", "qty": 5, "price": 8.00 }
],
"orderTotal": 0
}
// === Loop Node Config ===
{ "items": "lineItems" }
// === Iteration 1 (body port fires) ===
{
"current_index": 0,
"current_item": { "sku": "PRD-001", "qty": 2, "price": 15.00 },
"loop_total_items": 3,
// ... body nodes run, e.g. orderTotal += current_item.qty * current_item.price
// orderTotal = 0 + (2 * 15.00) = 30.00
}
// === Iteration 2 (body port fires) ===
{
"current_index": 1,
"current_item": { "sku": "PRD-002", "qty": 1, "price": 40.00 },
"loop_total_items": 3,
// orderTotal = 30.00 + (1 * 40.00) = 70.00
}
// === Iteration 3 (body port fires) ===
{
"current_index": 2,
"current_item": { "sku": "PRD-003", "qty": 5, "price": 8.00 },
"loop_total_items": 3,
// orderTotal = 70.00 + (5 * 8.00) = 110.00
}
// === Done port fires ===
{
"loop_total_items": 3,
"loop_completed_normally": true,
"orderTotal": 110.00,
"lineItems": [ ... ] // original array unchanged
}
Connecting the Loop in the Workflow Designer
Connect the body port to the first node of your per-item processing subgraph. The subgraph can be as simple or complex as needed — multiple sequential nodes, branching If Conditions, or nested API calls. The subgraph does not need a specific "end" node; when execution reaches a node with no connected output in the body subgraph, control returns to the Loop node to advance to the next iteration.
Connect the done port to whatever should happen after the entire collection has been processed — a summary notification, a database write of accumulated results, or another workflow trigger.