How to start back and beginning of loop if there is an exception

I have a Do While loop that is entering invoices online from a data table. If there is any error on an invoice, I want to skip the rest of the loop and start back at the beginning of the loop for the next invoice.

I already know how to use Try Catch. Is there any type of activity that can tell a loop to restart? It’s a pretty complex process and I’d rather not create a ton of If activities inside of each other if there is an easier way.



Do {
try {
//your processing logic
} catch (Exception ex) {
// your clean up code
} While i < dt.Length

Something like this?
Judging by your post, it seems like you already know what you need to do :slight_smile:

1 Like

Hi @atevis,

Take a look at the Retry Scope activity. Based on a condition it will retry the activities inside it and you may also set the amount of attempts there.

Or if you want to retry until every single invoice has been processed you could do something:

invoicesProcessed = False
    For each invoice in Invoices
        //process invoice
    End For  
    invoicesProcessed  = True
  End Try
While Not invoicesProcessed
1 Like

Thanks @acaciomelo

I will give Retry Scope a go.

In the invoice entry Loop, there are about 15 fields that each can have their own errors (mainly if they don’t match exactly what is in the system. I was hoping I could make a Try Catch for each entry with their own error conditions and if any of them throw an exception, it would skip trying to enter all of the other fields and just go back to the beginning. Ideally there would be an activity that in an If statement (exception = true) would tell it to go back to a certain point, similar to the feature in the flowchart. I feel putting a flowchart in the Loop isn’t the answer (although it might be, I haven’t really thought about it). Maybe just having an If statement around each step in the Loop with Then being Exception = false might be the way to go.

Thanks for the help! I’ll test Retry Scope.

1 Like