Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Workflow - Remove Items in one Collection that Exist In another

Created: 01 Sep 2012 | 3 comments

I am trying to use the Remove Items in Collection component to remove items in one collection if they exist in another collection. Both collections have the same data type. However, nothing is ever removed??? Is it matching on index or something?

Comments 3 CommentsJump to latest comment

AnaMan's picture

The component Remove Items From Collection uses Remove(..) method from System.Collections.ArrayList .NET class which is based on equality checking by calling Object.Equals(..).
The default implementation of Equals supports reference equality for reference types, and bitwise equality for value types. There is one exception - strings (Text data types) are treated as value type.

So, in your case, removing items from collection by pointing at elements from another collection will work only for collections of simple data types (Texts, Numbers etc.).

For complex data types you can solve this problem by using Configurable Collection Filter on base collection using as a filtering criteria elements from another collection and then pass filtering result to Remove component.

noodleNT's picture

do you need the remove component though? Configurable Collection Filter will already filter out the item.

Also, wouldn't you have to use the For Each Item in Collection then?

AnaMan's picture

1) Rigth, no, you don't. By using the Filter component you should get the same results.

2) There is no need to use Remove component inside For Each loop. The Remove Items components can take many elements on input, including collections, and it has its own internal foreach loop.