How to add more filters to the GetQueueItems activity?

Hello!

I wanted to ask if anybody can help me with ideas on who to add additional filters to the activity GetQueueItems.

Say I want to delete all queue items in a given Orchestrator queue that have the status New. Currently, I am using GetQueueItems activity (filtered with QueueItemStates=New), which returns a IEnumerable. Then I use the activity DeleteQueueItems to delete the queue elements that were returned. So far so good.

The GetQueueItems has a filter for Reference of the item, but what if I want to delete only those queue elements, that has a reference that is DIFFERENT FROM something? For example, the reference of my queue elements have a batchID and a row ID, and I want to delete all items that DO NOT have batchID [47]:

Queue Item with reference: “Batch ID: [45], RowID 1” (delete)
Queue Item with reference: “Batch ID: [46], RowID 1” (delete)
Queue Item with reference: “Batch ID: [47], RowID 1” (do not delete)
Queue Item with reference: “Batch ID: [47], RowID 2” (do not delete)

As far as I see I cannot use regular expressions for this, because the reference filter field can only contain a string.

So what are my options?

My idea has so far been to create a new (empty) IEnumerable, and only adding those items that should be deleted, and then feed it to the DeleteQueueItems. But searching online I am told that you can’t really add or delete items to an IEnumerable.

So what to do? What is the correct method for adding more filters to the GetQueueItems than are available by default?

I hope I have made myself understandable and that somebody can shed light onto this :slight_smile:

Thanks!

So, I found a solution. Writing it here in case anybody should stumble upon this in the future…

The method is this:

  1. Use GetQueueItems to retrieve an IEnumerable<QueueItem> of all items in a queue with status ‘New’.
  2. Loop through every item, and retrieve the Reference for each (could also be the Specific Content).
  3. If the reference of an item contains a value, that makes you want to DELETE that item from the queue, then add the item to a list of type List<QueueItem>.
  4. Lastly, after having looped through all queue elements, and having populated the List with all queue items that you want deleted, use the DeleteQueueItems activity and give the list as input.

That’s it! :slight_smile:

See the solution here: Delete queue items using search criteria.xaml (14.5 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.