Hi all
I have a list stored in a local variable on the server-side. I have to find whether more than 10 elements in the list have the same value and have to show an error if found. Is there any effective way to find this? (the list may contain more than 100000 records and it won't be stored in DB).
Thank you
Hi Prathoswar,
Depending on whether you know what you are looking for and if you need to let the user know what the duplicates are there are multiples ways to achieve this.
I would do this by starting with a list distinct to have a clean list. Loop this list and filter the original list on the current item. If this has more than 10 records in the list filter you know that the original list contains more than 10 duplicates.
If you add the item to another list (and keep on doing this throughout the loop) you will also know which items are duplicates as you can show these to the user at the end.
Max
Added an oml with a solution.
Hope it helps!
Paulo Rosário
Hello Prathoswar,
You can use the ListFilter action, where you set your Filter as the value you are looking for, and then use the Lenght attribute of that filter to check how many items on the list have that same value.
Please visit this link ..
https://www.outsystems.com/forums/discussion/71787/how-to-find-duplicate-element-in-list-with-the-help-of-outsystems/
hope it help you
Thanks ,
Kundan Chauhan
It's not the best solution but you can sort the list by attribute and simply check current record with previous record, if value is same then increase the count by 1 and if the count is greater then 10 then show the error.Hope this helps you.Thanks
Depending on your use case, you could use ListDinstinct and compare the lengths of the 2 Lists.