How can I rollback the Bulk inserted queue Item from Queue


I have 2-Queues, Queue-1 contains 2 file paths, based on this files(processing csv and pdf files and generating a data table) I’m creating a datatable and inserting this data table rows into Queue-2, on successful bulk insertion to Queue-2, I want to set the Transaction status to success. In between if the transaction failed after successful bulk insertion, transaction status would be “In Progress” after some time it would be “Abandoned”. Hence it will be retried next time. If Queue-1 transaction item is retried, again this data table rows will be inserted to Queue-2, how can I restrict this.

Any suggestion or help would be appreciated. Thanks.

Hi @RajuB,
I think it will be more clear to people if you could show some pictures and describe it step by step.

Sure @Pablito, I will give the screenshots.

Based on the below transaction item from Queue-1, I’m generating one datatable and inserting this data table rows into Queue-2 by bulk insertion.

After successful insertion to Queue-2, I want to update the Queue-1 transaction status to Success. If the transaction fails after bulk insertion and before updating the transaction status, how can I roll back the previous bulk insertion activity? Refer to the below screenshots.

Based on what you showed I’m pretty sure you can try to use try-catch activity or push your automation to ReFramework template where you can decide what can be performed if error will occur.

1 Like

Thank you @Pablito for your response.
I’m using try-catch, however, how can I delete the bulk inserted Queue-Items from the queue(in catch).

HI @RajuB,

When best to use Bulk Add to Queue?

  • When you know you have a datatable validated for all its Items.
  • When you want minimal number of calls to your Orchestrator from Robot

In your case, I would suggest using a normal Add to Queue but before that you can validate your data going to the queue and if the data going to the queue is not as expected, then an If condition does nothing. If Data is validated as true then Add To Queue. This however, will mean that you need a for loop.

But if you feel your architecture is good then you can try deleting queue items as suggested here: Why is there STILL no way to delete an In Progress Queue Item?! - Build - UiPath Community Forum In your case these will probably just be with status “New”.
Adaptation of this logic can be used in the Catch block but I would also suggest having a check that you are setting the status for the correct Transaction Item in Queue1.

Some final thoughts: Would an unique ID be a helpful thing to have as an item in Queue 1? This way you can look for the correct item in Queue1 before setting the transaction status?

Do post you final approach here, I am quite interested in learning what works in such a scenario.


Thank you for your response @jeevith,

Yes, delete the queue items in catch works for me. But how can I identify the recently created queue items(probably queue item status with “New” can help me to find out the same) but I have some other queue items with status “New” which are inserted yesterday, in this case, how can I delete the queue items which are inserted in the current iteration.

If I use the Add Queue Item, let’s say my data table has 100 rows and while inserting these 100 records my robot failed at the 50th record. Now the request comes to catch block and update the Queue-1 status to Failed. In the retry case, again these 50 records will be inserted into Queue-2. Hence the rows become duplicate, I want only unique items to be inserted into Queue-2.

Great you can cover one aspect of the issue.

The second question: To find New Items but which are may added a few seconds ago. Then you can use the inbuilt time filters in Get Queue Items activity.

The third question:
When the item fails to be added, you can use the index variable in the for loop and save it as a global value.

In the catch block you can then do:

  1. Use the Skip feature with index as value in add to queue to skip the number of items in the given time window (you have to decide the time filter). This way you wont have to worry about deleting the ones which are actually ok in the queue.

This is quite a tricky case so you have to test it with dummy data and queue. But essentially should work.

1 Like

Thank you so much @jeevith for your solution, I will try to implement the same and will get back to you if I stuck any where.

One quick question, If I use the unattended robot how can I filter Get Queue Items using the from time(I mean to say we don’t know the queue item creation time until we see in Orchestrator).

Hi @RajuB

Great. Try it.

You can in the time filter provide a datetime value

This will mean that any items added to the queue in the last one minute (remember to also include other filters mentioned above).

You may have to use both From and to

From: Now.addminutes(-1)
To: Now

I don’t remember exactly if the from and to fields in get queue take string or datetime. You will have to check what format it takes.

Your right, but here I have to identify the queue items which are created in the current loop. If I use Now.Addminutes(-1) (one minute), there may be a chance of getting other queue items that are inserted in the previous for loop or a chance of missing the queue items which are inserted in the current loop. In both cases, Index may help us I think. I will check that.
Thank you @jeevith