Comparison and removing element from List in nested loops

I am new to Mendix development. I am creating a new micro flow. I have a list of objects say List A with String elements (say list of employees) and another List B with  elements of type enumeration(say one element as enumeration type employeType). I need to remove the objects from the list if the value of one of the String type attribute (say employee type="Contract" ) of object is not one in one of the enumeration element in List B. How should i achieve it. So far I tried the following ways: 1) I add 2 loops nested. I iterate over List B, get the enumeration. Now I find in List Operation, the entire List A with type element same as getCaption(IteratorOverEnumeration_Employee_Type). This returns an instance, added a split to check if this is empty or not, if not,  remove from the list. The problem is that while finding it finds in the list not the iterator instance over List A. I should be comparing if the List Iterator value i.e. contract matches with List A iterator Type. 2) I added one loop over List B. I tried to add list activities like intersect, remove, subtract, but all of them expect the value as list type not the object type. Please suggest how do I achieve this.
1 answers

Hi Megha,

There are a lot of creative solutions to come up with. Probably even better than my following suggestion. What you can do is adding 2 helpers, first a list of the same type as A, named in my case "ListAList_ToRemove", second an extra boolean variable which you create on your listA iterator named "found". You set the default value of found to false, if you iterate trough list B you can change the value to true when it matches. Then after the loop of list b you check if the value of your variable is still false, if so you add it to a list to remove. After looping trough all items of list A you change your list A and remove all items at once with the created "ListAList_ToRemove":

And a modelshare of my microflow setup, note that it is created in 7.18.1:

Hope this helps you on the way!

Kind Regards,