Shapes

Control the run

Loop

Repeats a group of steps for each record, a set number of times, or while or until a condition holds.

Nodes › LogicOpen in Neblex
Good for
Repeating several steps
Role
Works on the records in a flow
Find it in
Nodes › Logic

When to use it

  • Page through an API until there is no next page.
  • Several steps should run per item, each with its own outcome.
  • A check should repeat until a status changes, within a maximum you set.

Reach for something else when

Example

Repeat a request while the response has a next cursor, carrying the cursor into the next round.

  1. Schedule
  2. Loop
  3. Data table

How it works

Settings
Iteration: For each record [default], Repeat a fixed number of times, While a condition holds, Until a condition holds. Collection path (optional) loops over a list inside each record. Repeat count. Maximum iterations [100] for while/until. Condition. Next iteration input (JSON mapping) for repeat/while/until, using output, state and index. Output: Collect body results [default] or Counts only. If a body fails: Stop the Loop [default] or Continue with the next iteration.
Body
Click Edit body on the node to build the steps that repeat. Inside the body the mapper offers loop values (index, current item, state, input) and Code sees loop_index, loop_item, loop_state and loop_input. Loops can be nested up to 8 levels.
Output
Collect: the combined results of the body's last steps. Counts only: {completed, succeeded, failed, canceled}. With Continue, a failed iteration adds {"iteration": n, "status": "failed"}. A while/until loop that reaches its maximum while the condition still holds fails, so it can never spin forever.
Example
Page through an API: Repeat while next_cursor exists, carrying {"cursor": output.0.next_cursor} to the next iteration.
More in the guide

Add it to a flow

  1. Open the flow from Build › Workflows.
  2. Open Nodes and find Loop under Logic, or search for it. Click it or drag it onto the canvas.
  3. Drag from the previous step's output handle to its input, then open its settings with ✎ Edit.
  4. Run the flow and click the step to see the records it received and produced.