Skip to main content

Break

The "Break" node allows you to exit a "For Each" loop prematurely. After executing the "Break" node, the flow continues from the bottom port of the inner "For Each" loop.

How It Works

  1. The node checks if it's currently executing within a For Each loop by examining the loop scope context (__fs flag)
  2. If a valid For Each loop context is found, the node marks the message with a special "BREAK" flag
  3. The flow exits the current loop iteration and sends control to the bottom port of the For Each node
  4. Execution continues after the loop without processing remaining iterations

Requirements

  • Must be used inside a "For Each" loop node
  • The For Each loop must be active and have a valid scope context

Error Handling

Error CodeDescriptionCause
Core.Programming.Break.ErrOnCreateConfig parse errorInvalid node configuration during creation
Core.Programming.Break.OnMessage (Message parse error)Message parse errorInvalid message format received
Core.Programming.Break.OnMessage (No foreach loop)No foreach loop to break outBreak node used outside of a For Each loop or loop context not found

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Usage Examples

Example 1: Stop Processing After Finding a Match

For Each (items)
├─ If (item.status == "completed")
│ └─ Break
└─ Process Item

When iterating through a list of items, stop the loop as soon as a completed item is found.

Example 2: Early Exit on Error Condition

For Each (records)
├─ Validate Record
├─ If (validation failed)
│ └─ Break
└─ Save Record

Exit the loop immediately if a record validation fails to avoid processing invalid data.

Example 3: Limit Processing Count

For Each (tasks)
├─ Increment Counter
├─ If (counter > 10)
│ └─ Break
└─ Execute Task

Process only the first 10 tasks from a larger list by breaking after a counter threshold.

Usage Notes

  • The Break node only exits the innermost For Each loop it's contained within
  • For nested loops, use multiple Break nodes to exit multiple levels
  • The node respects the "Continue On Error" setting - errors can be suppressed if needed
  • Delay Before and Delay After settings are applied even when breaking from the loop

Tips

  • Always ensure Break nodes are only used within For Each loops to avoid runtime errors
  • Use Break nodes to optimize performance by stopping unnecessary iterations
  • Combine with If/Switch nodes to create conditional loop exits
  • Consider using Break for search operations - stop iterating once the target is found
  • For Each - The loop container that works with Break
  • Switch - Conditional branching that can trigger Break
  • Function - Can contain loops with Break nodes