302
Views
6
Comments
Solved
How to find if 10 elements have same value in list?
Application Type
Reactive

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

2020-07-02 13-32-59
Max de Groot
Solution

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


2023-03-16 16-29-51
Paulo Rosário
Solution

Added an oml with a solution.

Hope it helps!

Paulo Rosário

10Elements.oml
2023-03-16 16-29-51
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. 

Hope it helps! 

Paulo Rosário

2023-03-16 16-29-51
Paulo Rosário
Solution

Added an oml with a solution.

Hope it helps!

Paulo Rosário

10Elements.oml
2026-03-12 06-20-48
KUNDAN CHAUHAN
Champion

Hi  Prathoswar,

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

2022-11-15 06-37-54
Ekjot Singh

Hello Prathoswar, 


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

2021-07-07 13-36-32
Hans Dollen

Depending on your use case, you could use ListDinstinct and compare the lengths of the 2 Lists. 

2020-07-02 13-32-59
Max de Groot
Solution

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


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.