Hi Beth. Thanks for making this suggestion. I will definitely file an issue for this request and raise it up with my team. I will update you here as soon as I hear anything from them. Cheers!
I agree. A loop becomes much more powerful logic if you can escape it. We could really use this feature.
Sorting would be great for Repeat Actions!
badly needed
Unfortunately, we do not have a native function that would escape a loop. However, we do have a suggested workaround. What you will need to do is have the loop nested in an error monitoring step, and have a stop with error within the loop when a certain condition is met. Upon receiving an error, the "on error" portion of the recipe will be started. An example of such a flow can be found in the link here: https://www.workato.com/recipes/962695?st=e9ecc4#recipe
As for a sorting function, you can use a ruby action to sort an array, or the collections feature in Workato.
Use formula mode and the .to_json formula on the list pill to convert it to a JSON array. After obtaining the JSON array, use the Ruby action and sort the unsorted object by entering the following code:
unsorted.sort_by { |hash| hash['key_to_order_by'] }
unsorted.sort_by { |hash| hash['key_to_order_by'] }.reverse
An example recipe can be found HERE.
2. Collections [Business Plus & Above]
After obtaining the JSON object, use the Collections by Workato action to
An example recipe can be found HERE.
Send us a ticket, we will try our best to assist you with your problem
Beth
Sort step and Escape Loop step
When in a For Each loop, it would be helpful to be able to sort the records, and to have an Escape Loop step, which would act like a Stop, but rather than stopping the whole recipe, would take you to the next step after the Loop chunk. This would allow for the equivalent of much more intelligent searching among a list.
Example use case, find the most recent open invoice for a customer in QBO:
Search invoices based on Customer ID.
Sort records in chronological order...
Loop...
Check the first one. Is its Balance>0? No?
Check next. >0? No?
Check next... >0? Yes!
Do things with this invoice.
Don't bother checking any more in the list; I'm done. Escape to next top-level step.
8 people like this idea