Flows/Utilities/Flow Control/Break Iteration

Break Iteration

Break out of an iterator loop early

Overview

The Break Iteration utility breaks out of an iterator loop when a condition is met. It passes the matching bundle (and optionally all bundles processed before) downstream and signals aggregators that iteration is complete.

Similar to a break statement in programming, this utility stops processing remaining bundles immediately.

Configuration

Source Module

Select which iterator's bundles to stop. Required for the utility to function. In nested iterators, this determines which level to stop.

Output Mode

Controls what bundles are passed downstream:

Match Only

Only pass the matching bundle that triggered the stop. All previous bundles are skipped.

All Until Match

Pass all bundles until the matching one, then stop. Previous bundles flow through normally.

Conditions

Define conditions using the same format as the IF utility. Supports text, numeric, date, array, and boolean operators. Multiple conditions can be combined with AND/OR logic.

Output

When a match is found, outputs include stop markers for the flow executor:

Output fields:

  • stoppedAtIndex - Bundle index where iteration stopped
  • originalTotal - Original total number of bundles
  • newTotal - New total after stopping (for aggregators)
  • All fields from the matching bundle are included

Examples

Example 1: Find First Active Item (Match Only)

Search through items and return only the first "active" one:

Output Mode:Match Only
Value 1:{{#1.status}}
Operator:Text: Equal to
Value 2:active

Only the matching bundle flows downstream. Previous bundles are skipped.

Example 2: Process Until Error (All Until Match)

Process items until an error occurs, keeping all successful results:

Output Mode:All Until Match
Value 1:{{#3.error}}
Operator:Exists

All bundles before the error flow through. Aggregators receive all successful items.

Example 3: Stop at Threshold

Stop when a numeric threshold is exceeded:

Output Mode:All Until Match
Value 1:{{#4.runningTotal}}
Operator:Number: Greater than
Value 2:1000

Process items until accumulated value exceeds 1000. All valid bundles are kept.

Tips

Tip: This utility must be used inside an iterator. It has no effect outside of an iteration context.

Tip: The current iteration will complete before stopping. If you need to prevent the current iteration from completing, use IF instead.

Note: When iteration stops, any aggregators will still receive all items processed up to that point.

Break Iteration Utility - Flows Guide - Serenities