Looping Through QueueItem

Hi,

I want to loop through all the items in the queue and retrieve few fields from each item. Get Queue Items is better to use or Get Transaction item?

how to loop through using get transaction item? I’m able to retrieve the fields using the get transaction item. HOowever that works for a single entry. How to loop through all the items in the queue?

Thanks : )

Hi @Yousuf_Ali

Well, considering the Get Queue Items and Get Transaction Item, i would suggest to use the Get Transaction Item when working with queue items unless you want to take all the queue items at once to done some stuff in all. However, when working with queues, the best approach would be to take one item at a time, process, update the status and then take the next item from the queue.

Get Transaction Item will only take one item at a time as you already explored it. So, you should run the entire program in a loop. To make use of the best features of the queue and to make use of the retry mechanism in case of a failure, I would suggest you to use the Robotic Enterprise Framework for your solution. This is the best mechanism to work with queues and handle errors along with the retries…

If you haven’t used it previously, I suggest the below…

Through this, you can create the solution

This is the documentation on the REFramework
REFramework documentation.pdf (507.8 KB)

Let me know if this helps

1 Like

HI,

I lnow i can use a flow chart and loop it back using a node. but if i am using a sequence is there a way to grammatically loop through?

Regards

1 Like

@Yousuf_Ali

Yeah, in case you are only considering this to be built within one workflow, yes, flow chart is a very good option to loop through as you already know… However, when it comes to the sequence, you will need to use loop activities to loop through the items.

So, when thinking of looping, the main concern is how many iterations should the loop run because we do not know how many items are available in the queue. So for that, I would suggest to use a infinite while loop. Why I say that is because you don’t know how many items are there in the queue (well obviously t his can be calculated using Get Queue Items), but the main point is, we do not know whether a item will be retried or not. And if retried, how many times each will retry. So we cannot limit our loop to a specific count until we are fully done with all the items though they get retried or not.

So, within the while loop, you can use the Get Transaction item activity to access each item from the queue. Then after that use a IF condition to check whether it has any value or not. Why do that is because we need to find the point to exit the loop if there are no more transactions to be processed :slight_smile: So you can use the IF condition and depending on the result, we can break the loop if there are no items to process, else we can continue… Once the processing of the item is done, make sure to update its status as well accordingly… The status should be updated as successful if the processing is successful for the item. If it ends of in an error, mark it as failed with application exception so that it will automatically allow the retry.

Additionally, in the queue, enable automatic retry and set the retry count as well…

Hope it helps.

2 Likes

Hi
That’s a good question and you got a good answer from uipath as well with a document

image

While if we want to manage that with sequence we can handle that with a while loop with counter variable less than total number of queue item as condition or queue item is null in a do while

Simple isn’t it
Cheers @Yousuf_Ali

one more clarification : In my case, i have to start the process by clearing the queue items. I am actually connecting to the queue and getting the transaction items for performing each transaction. But, the pending transaction which is not processed should be cleared out of the queue the next day before processing the transactions.

I checked for clearing queue items, and there is no provision to delete the transactions, instead… there is activity for clearing queue items. In such case - i am intending to get the queue item and then clear the queue item.

Questions :

  1. how to get the queue item and look in to the transactions (just to check if am doing right)?
  2. Also, is there any ways to delete transactions (which are new). or jus use delete queue items to delete the entire transactions? how it works?
1 Like