Making a custom retry

Hello

I am trying to construct a custom retry for my process that has a lot of consecutive steps on SAP as follows:

  • STEP A: Delivery Output => generates a delivery ref
  • STEB B : Invoice creation => generates an invoice number
  • STEP C : Shipment => generates a shipment number

Let’s say my process does my step A and B and fails at STEP C, I would want the process to resume back at the step it failed and not do it all from the beginning as it will generate duplicates

The issue is that each step needs the output data of the previous one

the step B needs the output number of the step A, the step C of the step B

My robot interacts with another application:

  • the app adds a queue item for the robot to process
  • the robot in the end sends an api request with the data created

Now, my idea was adding the status of each step into the transaction item, for ex:

DeliveryRef : “78842”
OrderRef : “8927”
StepA : “OK”
StepB : “”
StepC: “”
ShipmentNumber:“”
InvoiceNumber :“”

and this would be sent to the app so that If the app decides to send it back for retry I would already have the created data (the different numbers)

Now I am finding it difficult to decide how to handle the data in the cleanest most relevant way throughout the process

I have thought about using a datatable that i would fill throughout the process and then at the end of the process send back to the app, but I don’t know if it’s a good idea, and if i should initialize it in the init state or from the transaction item

this is quite complex any suggestion is welcome

thanks a lot

You could either use a separate queue for each step, or make use of the Progress of transaction items.

The progress field can be updated during the transaction processing and you could keep all updateable information for example in a serialized Dictionary.

1 Like

i did not know the progess field of transaction item, i like this idea better than to use multiple queues

so i should use the transaction item to trace the progress instead of a datatable ?

many thanks

Yes, that’s an option. You could even add a serialized DataTable to the progress field, if you want to. But if if it’s always going to have one row, a dictionary would be a better fit.

There are two options to do this

  1. With datatable

To construct a custom retry for your process, you can use a datatable to store the data that you need for each step. You can initialize the datatable in the init state or from the transaction item.

Here is a suggestion for how to implement this

  1. Create a datatable with the following columns:
  • DeliveryRef
  • OrderRef
  • StepAStatus
  • StepBStatus
  • StepCStatus
  • ShipmentNumber
  • InvoiceNumber
  1. Initialize the datatable in the init state or from the transaction item.

  2. In each step of your process, update the corresponding status column in the datatable.

  3. At the end of your process, send the datatable to the app.

  4. If the app decides to send the process back for retry, you can use the datatable to initialize the data for each step.

  5. With queues

you can use queues to implement a custom retry for your process.

Here is one way to do it:

  1. Create a queue for each step of your process.
  2. When a step fails, add the transaction item to the corresponding queue.
  3. Create a robot that monitors the queues and retries the failed steps.

The robot would work as follows:

  1. The bot would start by getting the next transaction item from the queue.
  2. The bot would then try to execute the step that failed.
  3. If the step is successful, then the bot would remove the transaction item from the queue.
  4. If the step fails again, then the bot would add the transaction item to the queue again.

You can also use a combination of queues and datatables to implement a custom retry. For example, you could store the data for each step in a datatable and then send the datatable to the retry robot. The retry robot could then use the data in the datatable to initialize the step before retrying it.

Which approach you choose will depend on the specific needs of your process.

Hope this helps

Cheers @adext

hello

i like the idea of initiating the DT in the init state
if i go for the first solution, how do i add the transaction item data into the datatable?

is it better to add them all in the beginning or throughout the process? like have a full datatable with filled order numbers but empty statuses that i would fill step by step or fill each row ?

thank you

1 Like

@adext

In UiPath, consider using a Dictionary or Dictionary(Of String, Object) to store and pass the data between steps, with step identifiers as keys and data as values, to maintain a clean and structured approach for retry and data sharing throughout the process.

cheers…!

@adext

using a Dictionary or Dictionary(Of String, Object) is a clean and structured approach for retry and data sharing in UiPath. You can initialize it in the Init state or at the beginning of your process, and then update and pass data between steps by adding key-value pairs for each step’s data. This approach makes it easy to manage and share data while handling retries or resuming the process.

cheers…!

hello

i find it easier to work with a datable throughout the process as i have multiple loops and multiple columns
however a dictionary is a very good idea for data sharing
i do not want to duplicate data in both datatable and dictionary so is there any way to mutualize the two ? like for example update my datatable and then convert it each time i need to share to dictionary ? or something else?
thank you

You can use ADD DATATOW activity to add data to the datatable you have if u want at beginning itself

You can add the transaction item data to the datatable in the beginning or throughout the process. If you add the transaction item data to the datatable in the beginning, you will have a full datatable with filled order numbers but empty statuses. This can be useful if you need to use the data in the datatable to initialize the data for each step.

Or

You can add Datarow with assign activity like

DataTable.Rows(0)(“Status”) = “OK”

If you add the transaction item data to the datatable throughout the process, you will have a datatable with the data for each step as it is completed. This can be useful if you need to track the progress of the process or if you need to send the datatable to the app at any point during the process.

Which approach you choose will depend on the specific needs of your process.

Hope this helps

Cheers @adext

Think the easiest solutions is creating the 3 workflows
Step A B C
And use a dt or sql to store the data that you have. In the catch you would check if step a is finished if it is go to b and c. Or if its missing for some data in A you start from there

Step A B C
Retry x number of times
try
A
B
C
catch
A
B
C
Throw