cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering a collection

GeoffreyAdam
Level 2

Hi,

I am having some issues with filtering a collection.

Situation:
I have a collection that contains a column "Status". I need to filter this collection on that column but not on a single value. I need to filter this column on more than one values, for example "Planned", "In Process", "New", ...

I can filter on a single value, but I cannot figure out the syntax for multiple values.. Pretty lame not?

I am using the "Utility - Collection Manipulation" Business Object and the "Filter Collection" Action. In the "Filter" input I am using following expression:

"Status LIKE 'Planned'"

This one works, but how do I manage to add the other values? Expressions like these won't work..

"Status LIKE 'Planned' OR 'In Process' OR 'New'"
"Status LIKE 'Planned'" OR "Status LIKE 'In Process'" OR "Status LIKE 'New'"


If somebody could help me out with this simple thing, that would be great!



------------------------------
Geoffrey Adam
------------------------------
2 REPLIES 2

Looks like a syntax problem. You'll need to treat 'Status' as a variable so that BP can compare the value of Status in each row against Planned / In Process / New.
You also don't need to use LIKE if you are not using wildcards

Try this:
"[Status]='Planned' or [Status]='In Process' or [Status]='New'"

------------------------------
Pratyush Garikapati
ROM Architect
Blue Prism
Asia/Kolkata
------------------------------

DiogoFurlan
Level 3
Hi,Geoffrey!

As Pratyush said the problem seems to be related to syntxax. If the value you are searching on the Status column changes dynamically, than you should use a variable. If you will always filter the same status (Like Planned, In Process and New) than you can try:

Option 1: "Status IN ('Planned','In Process','New')"
Option 2: "Status LIKE 'Planned'  OR Status LIKE 'In Process' OR Status LIKE 'New'"

If you want to have a deeper understandind how this action works you can take a look in the pages below
https://docs.microsoft.com/pt-br/dotnet/api/system.data.datatable.select?view=netframework-4.8
https://www.csharp-examples.net/dataview-rowfilter/

Cheers

------------------------------
Diogo Furlan
Analyst
Grupo NC
America/Sao_Paulo
------------------------------