Delete duplicates in BP Collection

m_razhes

New Member
Hi
I want to delete duplicate rows from the collection.

Input: Sorted rows based on column 3

Output: Remove duplicate rows based on column 3


Please refer attached screen shot.
Request you to share code stage for this problem.
Thanks
Raj
 

Attachments

  • BP Collection remove duplicates.png
    214.1 KB · Views: 48

Sachin_Kharmale

Active Member
Hey Raj,

Follow bellow steps to solve your problem ,

1. Add Action in Object Studio "Remove Duplicates form collection"
View attachment 1593090551171.png

2. Input Collection will be
View attachment 1593090573111.png

3. Code Stage Input and output
Input --> Input Collection , Column Name
Output --> OutputTable Collection
View attachment 1593090631240.png

C#:
   Hashtable hTable = new Hashtable();
   ArrayList duplicateList = new ArrayList();

   //Add list of all the unique item value to hashtable, which stores combination of key, value pair.
   //And add duplicate item value in arraylist.
   foreach (DataRow drow in   InputTable.Rows)
   {
      if (hTable.Contains(drow[colName]))
         duplicateList.Add(drow);
      else
         hTable.Add(drow[colName], string.Empty);
   }

   //Removing a list of duplicate items from datatable.
   foreach (DataRow dRow in duplicateList)
        InputTable.Rows.Remove(dRow);

   //Datatable which contains unique records will be return as output.
      OutputTable = InputTable;
4. Required Result after execution of code stage.
View attachment 1593090690372.png

I hope it will help you ...!!
 
Top