I have a requirement to find duplicate rows when a excel is uploaded looping through multiple records of the grid when multiple properties together serve as the primary key for checking duplicates and display the message “Duplicate Row” along with row number.Please help in achieving it.
@NikitaS39 You can try below approach.
Consider the excel that is uploaded contains 3 columns with multiple rows(Name,Age,DOB).
-
Once the Excel is uploaded data will be parsed and converted in to PageList. Each list object contains Name,Age,DOB that corresponds to a row in the Excel. Name of the Pagelist be OriginalDataList.
-
Formulate a temporary list by looping the OriginalDataList and concatenate all the three properties such that each list object contains only one property(pyLabel) with value of Name+Age+DOB. Name this Page list as ConcatenatedList.
3.Now loop this ConcatenatedList and for each iteration check whether same value exist or not using CountInPageList function. If the count less than equal to 1 means exit iteration else continue iteration and inside loop write Property-Set and take current index and concatenated values into local vaiables Eg. Local.RecordsIndex, Local.ConcatenatedValue.
- Write one more loop inside ConcatenatedList loop on same ConcatenatedList with pre condition as Param.pyForEachCount< Local.RecordsIndex exit iteration else continue when and specify one more condition as Local.ConcatenatedValue==ConcatenatedList().pyLabel then continue when else exit iteration. When condition is satisfied do a Property Set set as below:
Param.DuplicateInitialMsg=“Duplicates found for”+Local.RecordsIndex+" row are "
Param.DuplicateRecords=Param.DuplicateRecords+“,”+Param.pyForEachCount.
- Once the second looping is completed, after that step inside first loop do a Property-Set and remove trailing and leading commas using Whatcomesbeforelast and whatcomesafterfirst function with (,) as character. Append data to a page list with both concatenated values. Param.DuplicateInitialMsg+Param.DuplicateRecords
In this way multiple duplicate records can be identified for a record.