• Home
  • Preventing Duplicate Items on a Queue

How to prevent duplicate items in a Blue Prism queue

Preventing Duplicate Items on a Queue

Before you add new items from some source data to a queue it may be important to first check whether any of the items you want to add are already on the queue. An item is considered a duplicate if the Item Key is the same.

Duplicate Queue Contents

Remember when you set up the queue in the System Manager you provide a field from the data (Key Name) that becomes the Item Key.

Queue Contents

In the example to follow we want to add the rows in a collection called “CSV Values” to the queue without adding any dupicates.

Is the Item on the Queue?

You first check whether the new item is already on the queue using the Is Item on Queue action. This action is found in the Work Queues business object.

Action Properties

The compulsory inputs to this action are:

  • Queue Name – use the Data Item that has the name of the queue.
  • Key – use the appropriate field from the collection that you want to add to the queue. This must be the same field you used in the System Manager when setting up the queue.

The rest of the inputs control which type of items you want to include in the search. The default for each of these is True.

Action Properties

The output of this action is a flag indicating whether it found a duplicate or not. You can also store the Item IDs of all the duplicates. It depends on how you want to handle duplicates as to whether you need to store these IDs. If you just want to avoid adding any duplicates, then you just need a Data Item for the Result output.

This action needs to be placed inside a Loop since it can only check one key value at a time. Set the Loop Start to work through the collection containing the rows you want to add to the queue (in this example it would be CSV Values).

Queue Flow

After the action you will need a Decision stage which uses the output of the action.

Decision Properties

The rest of the steps in the Loop depends on what you want to do if there is already an item on the queue. One option is to simply not add the duplicate item. However, if the one already on the queue was processed a while ago and it may be appropriate to add this new one. In this article I will only cover adding the non-duplicates.

Adding non-duplicates to the queue

It might seem like all you have to do is link the no path from the decision to an Add Data to Queue action. The problem is that this action adds the whole collection to the queue and not just the row the loop is busy with.

To get round this you need to have a separate collection (e.g. Item for Queue as per picture below) to temporarily store the data from the current row of the loop. Set up fields in that collection to match the fields of the source data. You do not need to add an initial value.

You first need to add a new blank row to this collection.

Queue Flow

Use the action Add Row found in the Collections object.

Action Properties

Then using a Multi Calc stage you can transfer the data in the current row of the loop (i.e. CSV Values) to this Item for Queue collection.

Multiple Calculation Properties

You will then use an Add to Queue action. Note that the data added is the Item to Queue collection which is being used to store the current row of the loop.

Action Properties

You can get more information about the other inputs from the article “Using a queue in a Blue Prism process”.

Finally, you must remove the row from the Item for Queue collection. This is to ensure that you only ever have the current row of the loop stored in this collection.

Action Properties

By the end of this loop you should only have added data that does not already exist on the queue.