How can I make the robot get out of a For Each Row loop without breaking?

I have an excel file with multiple rows with information I need to use in the workflow. I’m using a For Each Row activity to gather the information and call several subprograms insdide the loop. Thing is, when an error happens, I want the bot to exit the loop without breaking/interrupting the workflow. I want it to go to the next activity outside the loop, but I don’t know how to do that. If the error occurs in the middle of the process, the bot will keep iterating through the excel file until the end. I need the bot to send an e-mail to the user explaining the problem. It has to be outside the loop, otherwise the user will receive dozens of e-mails for the same problem. Is there a way I can make the bot exit the loop without breaking?

Hello @cris-dsc,

Currently the For each row activity will process all the rows of list set as value. In order to have different errors handling and break the loop in a specific row, you could try to use the Do-while loop activity, so the workflow will not need to process all row of the list.

But if you need to use For each row, you could try to set a flag to identify when the error happen, and make a verification if the flag is on or off at the beginning of the loop, so if the flag is on it will just skip the process and continue until reach the end of the list and go to next activity after the for each row loop. It would be something like that:

Let me know if it helps

3 Likes

Yes, I ended up using a Do...while activity. It’s requires more work but it does the trick.

1 Like