I’ve come across a problem with figuring out how to move onto the next row if my workflow gets an error/exception. I just need to move onto the next row but the only solution i could think of was using “if” activity with the whole workflow in it again, but using this logic I would be needing and infinite number nested “if” activities.
I just want to know what solutions have you guys used in order to get around this limitation.
I think whether you are using a rowcounter in a Do while or Flow Chart loop, or no rowcounter with a ForEach, both methods would involve a Try/Catch.
So, surround the Sequence where the error can occur with a Try/Catch. Then you can store a variable with a string or the exception if desired. For a ForEach, it can just do nothing in the Catch and it will move on to the next row when it loops again. For a Do while, it’s the same except you should be doing rowcounter=rowcounter+1 at the beginning so it will move to the next row. For a Flow Chart loop, you can use that variable you store in the Catch to feed it into a Decision or Switch box so you can restart the loop if there were more tasks to perform, and you should also be doing rowcounter=rowcounter+1 at the start of the loop.
I will also point out that if you need to exit the loop to do things such as close all applications then reenter the loop again (by having the Try/Catch surrounding the entire loop), then using a rowcounter is beneficial in that you can keep track of the current row you are on (technically you can also do a counter in a ForEach also)
Sorry for no visuals. I’m just typing out some suggestions quick.
if using For Each or While loop, you can just use Try… Catch activity to go to the next row, if any error/exception comes.
Just put a Try catch activity in For each/while loop, and put all the code within it. Now if any exception occurred in the flow, it will move to the loop again.
While having a similar issue i have found an alternative that allows us to write errors as they occur and continue execution without stopping.
Within a For Each Row activity, initialize (re-use) boolean var, i.e. Assign ErrorFlag = False,
Then one can wrap the sequence or workflow that is to be executed within the For Each Activity with a Try-Catch Activity. On Catch, the flag is set to True (As an exception has been caught). On Finally block, an IF activity is used to write the status to the DT using the flag.
ForEachActivity block
a. Assign (Flag)
b. Try-Catch
b. (Try Block) Sequence
b. (Catch Block) Assign Flag = True
b. (Finally Block) If Activity
b. i. (If Activity Block) - If Flag = True
b. ii. Then write failure status to DT. Assign row.Item(Column Name on DT) i.e. Assign row.Item(“Status”) = Fail
b. iii. Else write success to DT. Assign row.Item(Column Name on DT) i.e. Assign row.Item(“Status”) = Success
Hi @amithvs,
You can use Continue Activity inside For Each loop, That got recently added in UiPath.
Alternate solution: Excel Scope For Each Try Catch Process to be done (If any error will occur, then it will go in catch, you can do exception handling there, and after that it will go and pick the next row)