cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Duplication from a collection but keeping related reference

LorenzoCapocci1
Level 5
Hi Team,
I would like to ask for your help to help remove duplicate details from column B but keeping on referenced to info in column A...
The result should be the same as from column C & D .
basically trying to the normal duplicate action removal, it would make me loose reference to column C, but I cannot have that happening.....

Are you able to help me?
Thank you
the duplicate work is done from Column B (D) as main check only
A & B is the original result
C&D is the desired result
I hope I was clear on this matter.


A B VS C D
BOM Id Standalone Stocked Item Id Standalone   BOM Id Standalone Stocked Item Id Standalone
S3100L GH88015601   B00ESF GH88301103
S3100L GH88015601   S3100K GH88301103
S3100K GH88301103   S3100K GH88301203
S3100K GH88301103   S3100L GH88301203
B00ESF GH88301103   S3100L GH88015601
S3100K GH88301203      
S3100L GH88301203      
S3100L GH88301203      
S3100K GH88301203      
1 BEST ANSWER

Helpful Answers

Hi Lorenzo,

We can use a LINQ object to get the unique records as per your requirement. You can create a new business object and add the below External References ('S
ystem.Data.DataSetExtensions.dll', 'System.Core.dll') and Namespace Imports ('System.Data.DataSetExtensions', 'System.LINQ' and 'System.Collections.Generic') on the Page Description stage of your Initialize action for the LINQ queries to work properly. Also, ensure that the language is selected as 'Visual Basic':

36343.png
Once you have the updated code options as shown above, create a new action named 'Get Unique Rows' and pass two input arguments, Input Collection (Collection) and Field Names (Collection). Based on the field names that you provide the unique records will be fetched from the Input Collection. Also, set an Output parameter as Output Collection (Collection) for this action as shown below:

36344.png

Add the code stage and use the below code with the input and out arguments as show:

Dim listOfFields = New List(Of String)()
listOfFields = Field_Names.AsEnumerable().Select(Function(dr) dr.Field(Of String)("Fields")).ToList()
Output_Collection = Input_Collection.DefaultView.ToTable(True,listOfFields.ToArray())


36345.png36346.png
36347.png

The run results are as follows:

Input Arguments:

36348.png
36349.png

Output Result:

36350.png

NOTE: For your use case you need to use both the fields 'A' and 'B' in the 'Field Names' collection then only it will take it in a group

You can publish the action and test the same from Process Studio. Let us know if this helps you out and please mark the answer as the 'Best Answer' if it resolves your query so that others can track the answer easily 🙂
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

View answer in original post

3 REPLIES 3

Hi Lorenzo,

We can use a LINQ object to get the unique records as per your requirement. You can create a new business object and add the below External References ('S
ystem.Data.DataSetExtensions.dll', 'System.Core.dll') and Namespace Imports ('System.Data.DataSetExtensions', 'System.LINQ' and 'System.Collections.Generic') on the Page Description stage of your Initialize action for the LINQ queries to work properly. Also, ensure that the language is selected as 'Visual Basic':

36343.png
Once you have the updated code options as shown above, create a new action named 'Get Unique Rows' and pass two input arguments, Input Collection (Collection) and Field Names (Collection). Based on the field names that you provide the unique records will be fetched from the Input Collection. Also, set an Output parameter as Output Collection (Collection) for this action as shown below:

36344.png

Add the code stage and use the below code with the input and out arguments as show:

Dim listOfFields = New List(Of String)()
listOfFields = Field_Names.AsEnumerable().Select(Function(dr) dr.Field(Of String)("Fields")).ToList()
Output_Collection = Input_Collection.DefaultView.ToTable(True,listOfFields.ToArray())


36345.png36346.png
36347.png

The run results are as follows:

Input Arguments:

36348.png
36349.png

Output Result:

36350.png

NOTE: For your use case you need to use both the fields 'A' and 'B' in the 'Field Names' collection then only it will take it in a group

You can publish the action and test the same from Process Studio. Let us know if this helps you out and please mark the answer as the 'Best Answer' if it resolves your query so that others can track the answer easily 🙂
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

LorenzoCapocci1
Level 5
Thank you so much @devneetmohanty07 , just tested it, and looks like is doing what I needed, I will try further as I need more example,,, but I like this code, I really appreciate all details provided...​

Glad your query got resolved and my solution could help you out Lorenzo:)
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.