cancel
Showing results for 
Search instead for 
Did you mean: 

Filter Collection

RichardLoughins
Level 4
I'm having some trouble filtering a collection using a value that's stored as a data item.  Let me explain what I'm trying to do: I've got some Work Queue Items, which when retrieved from the WQ contain a field called "Resource ID", and the value for this field has in turn been stored as a data item.  The value of this field should correspond with a field in a collection called "Work Order ID".  The collection could contain multiple rows matching this Resource ID/Work Order ID and I need to extract all of them into a separate collection, hence the use of 'Filter Collection'. However, I can't seem to get the Filter collection's 'Filter' input to retrieve the value of a data item.  For example, the following will work: "[Work Order ID] = 'ABC123456'" but if I try and use the following: [Work Order ID] = [Resource ID]  I get a null return. I've tried a range of combinations including "[Work Order ID]" = [Resource ID] but nothing seems to work.  When I entered [WO Entries.Work Order ID] = [Resource ID] it returned the whole collection. Can Data Items not be used with the Filter Collection action?
1 BEST ANSWER

Helpful Answers

Mustafa_UlasYig
Level 6
Hi Richard.Loughins Sure they can. Let's say you have a collection called ""Collection 1"" with a field called ""Work Order ID"", then you in Utility - Collection Manipulation action ""Filter Collection"" specify ""Collection In = [Collection 1] and Filter = ""[Work Order ID] = '"" & [Resource ID] & ""'"" Notice the characters after = '  "" & and & ""  '  "". That should do the trick. Good luck. BR, Mustafa

View answer in original post

11 REPLIES 11

Mustafa_UlasYig
Level 6
Hi Richard.Loughins Sure they can. Let's say you have a collection called ""Collection 1"" with a field called ""Work Order ID"", then you in Utility - Collection Manipulation action ""Filter Collection"" specify ""Collection In = [Collection 1] and Filter = ""[Work Order ID] = '"" & [Resource ID] & ""'"" Notice the characters after = '  "" & and & ""  '  "". That should do the trick. Good luck. BR, Mustafa

RichardLoughins
Level 4
Works great Mustafa, thanks very much for your help with this!  Much appreciated

Mustafa_UlasYig
Level 6
No problem Richard 🙂 Love the strange syntax of BP! Have a great day...

Hi Mustafa, Wanted your advice on how to apply 2 filters at once in a Collection. I want to apply filter for finding stock of Apples in East region. Any suggestions would be appreciated. Thanks

Region Fruit Stock Grade
East Apple 10 A
East Orange 15 B
West Apple 20 A
West Orange 25 B
West Grape 30 C


------------------------------
Aarti Bansal
Automation Associate
S&P GMI
Indian/Chagos
------------------------------

I'm adding a C# code stage that should handle this.

Inputs:
Collection - Collection
FilterString - Text (For this particular example, the value would be "`Region` = 'East' and `Fruit` = 'Apple'" (with quotes))

Outputs:
Sorted Collection - Collection

String filter = "";
if(FilterString!="")
{
	filter = FilterString;
}
DataView dv = Collection.DefaultView;

	dv.RowFilter = filter;

Sorted_Collection = dv.ToTable();


------------------------------
Ami Barrett
Lead RPA Software Developer
Solai & Cameron
America/Chicago
------------------------------

Ami, any reason not to use filter action in collection manipulation?
I know default VBOs are mostly bad, but it should work.

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

When I first started using BP, we were still on v4. I'm not sure if the VBO had been modified, or if the action didn't exist at that time, but I wound up having to write it from scratch.

To my knowledge, it's good enough to use OOB. I just don't really go into the original version of that VBO anymore, haha. (That and I have a slight obsession with using C# for the sake of maintenance.)

------------------------------
Ami Barrett
Lead RPA Software Developer
Solai & Cameron
America/Chicago
------------------------------

Hi,
please could you use filter action in collection manipulation? thanks

------------------------------
Amby N
------------------------------

Hai richard iam facing same issue like you
can you please show your Filter arrangement here
MY Filter arrangement is "[Site ID] = '[Site name]'" but its showing null
please help me to for my filter arrangement as per mustafa idea 
[Site ID] = My header
[Site name] = My data item

------------------------------
Narayanamoorthy N
------------------------------