29
Views
4
Comments
Two List of Differents Data type.
Application Type
Reactive

Hi guys, I need some help with a problem I'm having trouble understanding...

Unfortunately, I can't share the OML or code, but I'll try to explain it step by step:

I have 2 Lists, from different entities that arrive via Input Parameters... in my Action:


List1 from Entity1:                                List2 from Entity2:

A                                                               A

B                                                               C

C


I need to update List 1 according to List 2 dynamically... In this case, since I don't have Record "B" in List 2... I need to not have it in List 1 either, i.e. I need to delete this "B" record, because it is no longer in List 2.

Remember that lists are different types of entities... The 2 lists have a common attribute which is not an ID.


Thanks ! :)

2022-07-11 14-05-36
Jeroen Barnhoorn

Hi Gustavo,

If List1 and List2 are of different entities, how is it possible to have Record A in both lists? Do you mean that both entities have a similar attribute and both lists contain a record with the same value for that attribute (e.g. Entity1.Name = "A" and Entity2.Name = "A")?

2022-06-30 21-50-41
Gustavo Mor

Exactly, I forgot to mention that... the 2 do have a common attribute that is not an ID.

2022-07-11 14-05-36
Jeroen Barnhoorn

Then I would probably use a foreach loop to iterate over List1 and a ListIndexOf to see if each element also exists in List2. 

Since you cannot delete from a list you're iterating over, I would instead copy the records that are in both lists to a temporary list and use that list to replace List1 at the end of the loop.

UserImage.jpg
Milind Bansal

Hi Gustavo,

First you have to call the duplicate list action (System Module Provide) for List1 then Iterate the for each on duplicate list that is returned from Duplicate list action and perform the comparison check with List 2 using List any action provided by System module if ListAny action result is true then continue the loop else remove the element from List 1 using List remove action from System module to passing the input as List 1 and Position as CurrentRowNumber from Duplicate list and continue the loop.

Thanks 

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