List operation: Not equal - Mendix Forum

List operation: Not equal



I am struggling to do something that seems like it should be very easy.

I have two lists of objects; I want to to remove objects from the first list whose attribute matches that of an object in the second list.

Here is the equivalent javascript:


   list1.filter(ob1j => !list2.find(obj2 => obj2.attribute === obj1.attribute))


I can't do the List 'subtract' operation since it only operates on ID's. So, I put a loop over list2, but then the operation I want is 'Not Equals'...List operations only offer 'Equals'


Is there a simple way to do this?


2 answers

Or if you want to use default Mendix: Loop over List2 and use a find or filter from List1 with the attribute of the iterator in the loop. If it matches remove the found objects from List 1. After the loop you would then have all the objects that do not have a match with List2 in your List1.


Check the appstore for "ListUtils ". That will give you more power over managing your list. Might get you what you need.