BreakLoop exits a composite rule based on a number of loop (iteration) values. More specifically, it exits a looping ("For each") Composite Rule based on an indicated numeric value (numberOfLoops).
This can be used to short-circuit a loop once you have what you need, improving both performance and control flow in your ruleset logic.
Typical use case: Stop processing once a match is found
The most common scenario is iterating through a list of records and stopping as soon as a condition is met, rather than continuing to loop through every remaining item unnecessarily.
Example: Finding the first valid line item on a purchase order
You have a "For each" loop iterating over all line items in an inbound EDI order. Once you find the first line item where quantity is greater than zero, you want to stop and process that item. There is no need to keep looping.
| Property | Value |
|---|---|
| numberOfLoops | 1 (exit the current loop level) |
When the condition is satisfied (e.g. a BooleanEquals check returns true), BreakLoop fires and exits the loop immediately.
Exiting nested loops
If you have loops nested inside each other, you can set numberOfLoops to a higher value to break out of multiple levels at once. For example, setting it to 2 would exit both the inner and outer loop in a single action, rather than having to chain multiple BreakLoop actions.
Comments
0 comments
Please sign in to leave a comment.