Reframework Error Handling In for loop

Hi I am using Reframework process.
I have a excel which has 3 rows to be processed.
I am using for each loop to process all the 3 items in the Excel
Using try catch activity inside for loop for error handling. So any error occurs I need to perform set of operations I placed under catch activity.
I need to process all the 3 items and If any exception happened in any one of the items in the Excel I need move to catch block at the end of the transaction.
1st item success 2nd item exception 3rd item success.Now bot move to catch block and handle exception. How can I do that in try catch?

Hi @Priyanga_Karnan

Since you are using RE Framework & reading data from excel, let’s get 2 important points clear:

  1. RE Framework is by default a loop, you don’t have to use for each again. This is because RE Framework is designed for transactional processing & failed transactions shall not break the iteration. It will treat each row as an individual transactional entity & performs the action associated with either success/failure case.

  2. RE Framework is by default designed for queue items transactions & you need to configure it if you want to use excel data (datatable). You have to make some changes to the workflow & you are good to read excel data in the init state & pass the same to process state.
    Please refer this video on how to make such changes:
    Using ReFramework with Datatable|Transaction item as data row|#vajrangtalks|#uipath - YouTube

Once you are clear with these things-
i. Read the Excel data in init state & store it in the data table.
ii. Pass each data row in the get transaction state.
iii. Process each row individually in the process state. This state is by default surrounded by TRY CATCH. Perform the successful actions in Try. If not, throw an exception in try & the control comes to catch & perform the failure actions in CATCH.
iv. Set transaction status for each data row based on success/failure state.
v. End the operation by closing any applications or windows in End state.

Hope this helps, please let us know if any further assistance is required.
Best Regards.

Hi Arjun,

The Excel which I am referring will get it from queue items. The Excel may contains 1 or more items. If it has more than 1 items then it follows as below

  1. Success - perform some sequence (all the items are success)
  2. Failure - perform some sequence ( if any of the item is failures)
    But both should be done only at the end of the transaction
    Here the Excel is treated as one transaction.

My logic
I will loop through the Excel

  1. If 1 st item success - add to a data table
    2nd item failure - add to the data table as failure
    3 rs success - add to table and I will check if the Excel rows and data table rows are same if it so I will filter the data table and check if it contains failure if it so how can I go to catch block and perform some sequence for exception
1 Like

@Priyanga_Karnan


@Priyanga_Karnan

You are almost there…

You have teo options here…

  1. Use a boolean variable and set it to False by default and use a assign activity in the catch block and set the value to True and then after the loop use a if condition with the booleam variable and on the then side use a throw activity…

  2. As you already adding status to datatable as success and failed…after filtering with failed check the filtereddt.rowcount >0 in the if condition and on then side again raise an exception

Hope this helps

Cheers

1 Like