In Mendix, the Union list function is designed to remove duplicates, but sometimes it may not behave as expected, especially if the items in the list are complex objects rather than simple values like strings or numbers. When dealing with lists of objects, Mendix checks for equality by comparing references (or object identities), not by comparing the actual content of the objects.
one approach is to manually check for duplicates by looping through the list and checking the properties of the objects.
You are doing the union in the loop and then discarding the results
You need to do the union after the loop and use the resulting list