I need to exit the for each row loop if a specfic activity in my automation fails

Hey everyone,

I have built an automation which interacts with few websites based on the data in google sheets, Inside For each loop, if this specific activity “which clicks on a certain icon” fails I want the loop to exit and resume to the next row without executing the rest of the activities. Please guide.

Welcome to the UiPath Community @Asad_Afzal1!

Use Try Catch activity inside the for each loop and put your activities inside Try section.
This will ensure if any activity fails inside this it will continue on next iteration.

In catch section you may log the activity details which is failed for reference if you required.

1 Like

Hi @Asad_Afzal1 ,

If you want the activity to continue only when the click activity receives an error, use the activity in a Try Catch and put the activity Continue in the Catch.
This way, it skips the activities after Click and moves on to the next row.

Hii @Asad_Afzal1 ,

Welcome to UiPath community!

You can use check app state/element exists activity inside for each loop after clicks on a certain icon, if next screen appear then perform other activities otherwise use Continue activity for perform next transaction.

I hope this will help you!

Remember to mark the solution so that others can find it more easily.

Best Regards,
Ronak Patel.

@Asad_Afzal1 I would second @ashokkarale’s solution. It solves your problem, so please mark it as the solution. One thing to keep in mind: if you want to do it your way, the applications will remain open, so you’ll need a recovery mechanism to prevent them from interfering with the next “for each” item. Cheers!

Hey @ashokkarale, thank you for responding.

However, there are few activities of less significance, if failed I want the automation to move forward and for which I am using “Continue on Error” property.

My concern is if this one activity fails, the automation should move onto the next iteration only.

Ok @Asad_Afzal1 then in that case put “this one activity” in try catch and in catch section use Continue activity