Finding an item in the queue item array

I need to check if an item is in the queue item array. How do I do this without using a loop?

@redanime94 ,

Can you specify what exactly you want to check, whether it is a field value inside queue item or if a field name ?

Regards,

It is a field value inside the queue item

Hi

Get the queue items with GET QUEUE ITEM activity where u can use some filter strategy u need to check whether a queue item is there or not without looping

If the output has some value then it is there in that queue

Cheers @redanime94

@redanime94 ,
Try the following:

Replace the FieldName and ValueToCheck

(from item in QueueItems where item.SpecificContent.ContainsKey("FieldName") andalso item.SpecificContent("FieldName").ToString.Contains("ValueToCheck") select item).Count

Here, if the count is greater than 0, you can confirm that the value is present in the queue items.

Regards,

I am getting this error: “Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.”

Check the double quotes, it should be straight instead of the curved ones.

This-> "

Regards,

It worked… but I am getting a zero result :frowning: is that .ContainsKey(“FieldName”) the same value as the .SpecificContent(“FieldName”), i.e. say I am looking for a “CustomerNumber” then the FieldName in both should be CustomerNumber?

Yeah field name both you should provide the name like “CustomerNumber”

Regards,

I am getting zero result

This is what I have done:

The arrMatch is looking for the latest run of the item…

Can you display where you have used the expression ? @redanime94

Regards,

@redanime94 , for example the below shown image the Custom1 is the filed name and the d is the value hence, the expression will be:

(from item in QueueItems where item.SpecificContent.ContainsKey(“Custom1”) andalso item.SpecificContent(“Custom1”).ToString.Contains(“d”) select item).Count

image

Regards,

(from item in arrMatch where item.SpecificContent.ContainsKey(“CustName”) andalso item.SpecificContent(“CustName”).ToString.Contains(“strCurrentCustNumber”) select item).Count

image

I guess this is a variable you are passing? if it is then you need to avoid the quote.

Regards,

Hmmm - posting the image I think I know where the error is… :slight_smile:

1 Like

Yup that’s a variable being passed

1 Like

It’s working now - I am getting a value. Thanks for the help.

1 Like

@redanime94 ,

I hope you got the error fixed, variables should be passed without double quotes.

Regards,

Yup it’s working. Thanks for that.

1 Like

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