cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Break the For Each based on the condition

Rajesh_Nadella
Deputy Chef II
Deputy Chef II

Problem: Break the loop based on the if condition satisfied and continue to the next steps. is this can be achieved in workato.

1 ACCEPTED SOLUTION

manojksurisetty
Deputy Chef II
Deputy Chef II

Based on your question, it seems you need to iterate over a list of values, exit the loop when a condition is met, and then proceed with the remaining steps in the recipe. (Please correct me if I've misunderstood.)

Currently, Workato doesnโ€™t support a direct โ€œbreakโ€ statement to exit a For each loop. However, you can simulate this behavior using conditional logic. Here's a workaround approach:

1. Initialize a flag variable (Boolean, default: false) outside the loop.
2. Loop through the list of items using the For each action.
3. Within the loop, apply your primary condition to determine whether to stop further execution of loop actions. Combine this with a check on the flag variable (e.g., flag == false) so that the logic only runs before the break condition is triggered.
4. When the condition is met, set the flag variable to true. This ensures subsequent iterations skip the logic.

Outcome: The loop still iterates through all elements, but after the condition is met, no further actions inside the loop are executed โ€” effectively mimicking a break.

View solution in original post

6 REPLIES 6

Thanks for the response, able to find the solution from above.

sridevib
Deputy Chef II
Deputy Chef II

Hi @Rajesh_Nadella 

If you need to process only until a match is found and then skip further logic, you can filter the list to reduce size. Use a flag (variable) to skip logic after condition is met.