Break Loop
Exit the current loop iteration prematurely based on a condition.
The Break Loop block is used to immediately stop the execution of a Loop and jump directly to the After Loop section.
This is particularly useful when searching for a specific item in a list or when a certain success/fail condition is met that makes further iterations unnecessary.
Configuration
This block does not require any specific input configuration. Its mere execution triggers the loop exit.
The Break Loop block must be placed inside a loop's iteration path (connected after the Loop Iteration block). If executed outside of a loop, it will have no effect.
How it Works
When the logic flow reaches this block:
- The current iteration is halted.
- All remaining items in the array or remaining counts in the range are skipped.
- The workflow resumes from the block connected to the After Loop helper.
Error Handling
This block triggers a control signal rather than a data operation, so it does not produce standard user-facing error keys. If the loop fails to break, ensure the block is correctly connected within the loop's path.
Example: Finding a Specific Value
Suppose you are looping through a list of items to find one with a specific id.
- Place a Compare block inside your loop.
- Set the condition to check if
{item.id}equals{target_id}. - Connect the Success path of the Compare block to a Break Loop block.
- Once the matching ID is found, the loop will stop immediately, saving processing time and preventing unnecessary cycles.
