Finding Duplicates from the list and displaying them separately in a page

0
How can I filter and display only duplicate records from a list in Mendix without adding the same duplicates multiple times?   I have a list of around 10,000 Program objects, each with a ProgramID attribute. Some ProgramIDs appear more than once. I want to show only the records that are duplicates — meaning ProgramIDs that occur more than once — on a separate page. The issue I'm facing is: When I loop through the list and find duplicates, I end up adding the same set of duplicates multiple times. For example, if ProgramID = 101 appears twice, both records get added again when the loop encounters the second instance — resulting in 4 records instead of 2. What’s the best way to: Identify which ProgramIDs are duplicates Collect only one set of those duplicates Avoid adding them multiple times in the final list Any help with the logic or best practices in Mendix Microflows would be appreciated!
asked
1 answers
2

Simplest is to:

  1. retrieve all 10000 in a list, result "ListAll"
  2. Use List -> Union, adding your "ListAll" list twice. result "ListUnified"
  3. Use List -> Subtract, subtracting  "ListUnified" from "ListAll". result "ListDuplicates"

But this might be slow because of the in-memory list of 10000 objects.

Alternative: Use OQL to retrieve all duplicate ids. Something like:

from module.Program as p 
group by p.ProgramID 
having count(p.ProgramID) > 1
select p.ProgramID

Second alternative is a microflow in which you retrieve Program ordered by ProgramID, looping over it, checking if p.ProgramID is the same as the previous.

answered