Skip to main content

Loop (container) node

Decision

What it does​

The Loop (container) node is a region on the canvas. The nodes inside it, the body, run once per iteration: per item in a list, a fixed number of times, or while a condition holds. The rows from the body's last node are collected across every iteration and leave on out as one stream.

When to use​

  • Each item needs several steps, such as a call to another system and then a transform.
  • The steps should be visible as one block on the canvas.
  • You need a while condition with real work inside it.

Loop and Loop (container) both iterate. Pick by what happens per item.

You want toUse
Turn a list field into one row per itemLoop
Repeat each row a set number of timesLoop
Run several nodes once per item, shown as one blockLoop (container)
Repeat work while a condition holdsLoop (container)

A Loop sends all its output rows to the next node together. A Loop (container) runs its body once per item and collects the rows on out.

A container runs its body once per item, so 10,000 items means 10,000 passes. If a Transform or a Compute over the whole set does the same work, it is much faster.

Configure​

Select the container by its header and press Configure to open Configure Loop container.

Save and Done stay unavailable while a required setting is missing. Cancel discards the changes made since the dialog opened or was last saved. A message confirms each save.

Iteration mode

  • Foreach: one body pass per item in List field (array), for each input row. The box suggests upstream fields with their types, and also accepts a nested path such as order.line_items.
  • Fixed count: the body runs Count times per input row.
  • While: the body runs while While expression is true, for example LT(index, 100).

Iteration variables: Item variable name (Foreach only) and Index variable name, item and index by default. The body reads them as {{var.exec.item}} and {{var.exec.index}}. The index starts at 0.

Guards

  • Max iterations: default 10,000, from 1 to 1,000,000. The loop stops at this count.
  • Exit expression (optional): the loop stops when it is true, for example GT(index, 10000).

Parallelism: Parallel iterations is 1 by default, one pass at a time. A number from 2 to 32 runs up to that many passes at once. auto sizes it for you.

Validate checks the settings that make a loop run zero times:

CheckLevel
The list field, count or condition for the mode is missingError
The item and index variables have the same nameError
The list field is not produced by any upstream nodeWarning
The list field is a single value, not a listWarning
The container has no body nodesWarning

Warnings do not block saving, because upstream fields are not always known in advance.

Build the body​

  • Add a node: drag it into the container and release. Drag it out to remove it.
  • Connect body nodes with normal edges. Edges do not cross the container's edge: connect the upstream node to the container's in, and the container's out to the next node.
  • The last node: the body's rows come from its one node with no outgoing edge inside the body. Give the body exactly one such node.
  • Body nodes are shown at 75% size, and return to full size when dragged out.
  • Move: drag the container's header to move it with its body.
  • Resize: select the container and drag the handle in the bottom-right corner. From 340 by 200 to 1600 by 1000.
  • Collapse: the chevron in the header folds the container into a compact card. The body still runs.
  • Move several nodes: Shift-click or box-select nodes, then drag one of them.

Ports​

PortDirectionKindNotes
inindataInput rows. Each iteration feeds the body's first node.
outoutdataRows from the body's last node, from every iteration.
erroroutcontrolReceives the input rows when the container fails, including an exit or while expression that cannot be evaluated.

How it runs​

  • Variables and caches set before the container are available in the body.
  • The run view shows the iteration count, and body node samples per iteration.
  • A body node that fails makes the container fail. The error names the node and the iteration.

Examples​

Two calls per customer.

  1. Add the container and size it
    Drag the corner handle until the body nodes fit.
  2. Drag the body nodes inside it
    Release each node inside the container. Connect them so one node ends the chain.
  3. Choose what it iterates
    Foreach on a list column, Fixed count, or While.
  4. Set Max iterations
    A limit for lists longer than you expect.
  5. Press Validate
    Fix any errors before you run.

Run a configured node per order line. Foreach on line_items. Inside: a Node Call with a binding to {{item.sku}}, then a Transform that keeps the fields you need.

Troubleshooting​

SymptomCauseWhat to do
The container outputs no rowsThe body is empty, or the list field is empty.Press Validate and fix what it reports.
Loop container body has 2 terminal-node candidatesTwo body nodes have no outgoing edge.Connect the body so one node ends it.
Loop container body has no terminal nodeEvery body node has an outgoing edge, which forms a cycle.Remove the edge that closes the cycle.
Fewer iterations than expectedMax iterations or the exit expression stopped the loop.Raise the limit or check the expression.
The run is slowThe body runs once per item.Raise Parallel iterations, or do the work over the whole set in a Transform or Compute.