โ09-15-2023 02:39 AM
How to escape from a repeat loop in workato when a specific condition is met? Repeating entire list and check condition is bad for the performance.
I don t want to use monitor functionality and throw error to escape from the loop.
is there any alternate solution present?
Solved! Go to Solution.
โ09-19-2023 10:25 AM
If you're calling SF within the loop and you need the SF response/flag to break the loop, then the simplest way to accomplish this is to use the error monitor. It does exactly what you need and will not process the full list once the loop is broken. You can configure it so it does additional processing after the catch/break.
Is there a reason don't you want to use the error monitor?
โ09-20-2023 01:13 AM
Another possible workaround to this is to utilize a Recipe Function. Within the Recipe function, include the necessary loop and condition. Once the condition is met, use the Return function to exit the Recipe Function and return to the parent recipe.
โ09-20-2023 07:08 AM
Yea I agree about the Monitor/Error block. I resisted using it at first b/c it felt un-intuitive and a bit of an eyesore for this purpose, but I embraced it b/c it's easy. The recipe function idea is a good one too, but you may want to save the task usage if you'll be calling this recipe (and/or the function) many times.
โ09-22-2023 03:04 AM
Hi @prp_proton ,
It depends on your use case; for example, if you want to stop the loop after several lists or indexes, you can add a condition and a monitor action to move to the next step in the recipe. Here's an example:
โ09-21-2023 01:35 AM - edited โ09-22-2023 05:33 AM
The content has been removed for clarity purposes.
โ09-21-2023 05:48 AM
Javier,
It has always been my understanding that calling a Recipe Function consumes a task. It was a big bone of contention for me when I found out and I brought it up to my CSM multiple times. I've never heard back that it didn't consume a task. When I read your post I thought maybe Workato had changed its policy to ignore those actions now, but in looking at a job this morning it still seems to be consuming a task:
โ09-22-2023 05:31 AM - edited โ09-22-2023 05:35 AM
mppowe
You are correct. Calling a recipe function will consume 2 additional tasks per loop: one when calling the recipe, and another for the Return action. Please refer to the screenshot below for reference.
โ09-22-2023 09:56 AM
If we are using the catch break..... it will show error in the job report. which is actually misleading. Thats why looking some another solution.
โ09-22-2023 10:10 AM
If you're referring to the error monitor, it doesn't automatically mark a job as failed in the job report. The job viewer will still show which action had the error, but the job could be configured to stop successfully or failed.
Job report:
Job viewer: