โ03-14-2022 09:17 PM
Hello Workato Community,
Is there a way to exit a ForEach loop given a specifc condition (like in a WHILE statement)?
I'm just looking for an ID in a list and I want to stop the ForEach once the ID is found.
I added an IF condition inside the ForEach but, as per my understanding, this would just prevent the following steps inside the ForEach from being executed, but the ForEach would still need to iterate through the whole list.
Thank you,
Filipe
โ03-14-2022 09:32 PM
This is the only way that I am aware of the do it. I know it seems like a waste of cycles but the iteration happens pretty quickly. This feature is much much needed and long overdue.
โ03-15-2022 02:23 AM
Vinny and I just discussed this recently. You can submit product feedback on this.
โ03-14-2022 09:41 PM
You could call a function to iterate on the loop and then return response/stop job from the function when it meets the criteria. You would still need a list to iterate through in the function.
โ03-14-2022 10:01 PM
sometimes the .where function can help prevent unnecessary loops.
I also echo Vinny, as an engineer I hate wasting electrons but a simple if statement also gets the job done. I have tried many different ways of breaking a loop in Workato and it didn't work out well - so now I just keep it simple.