392
Views
6
Comments
Solved
How to Combine Two Different Lists  so as to form one List?
Question
Application Type
Reactive

Hello all


I am Having two Different Lists (Say List1 and List2)  and i want to Take Few Columns(Or Attributes) from First List and Few from Second list so as to form New/Resultant List.

Note : Bothe List1 and List2 i am getting from API's hence Local data base is not exists.

Please Suggest Solution.


Regards

Sanjay

2023-05-30 10-05-13
Lourenço Matalonga
Solution

Hi @Sanjay Bankar ,

so if you are getting those two lists from an api  the output of those API is a record list. Ok, you have 2 different record lists and you want to have a final list that includes some columns from  List1 and some columns from List2. Then you will need to create a new structure with the attributes that you want one the final list. Something like this:


You have List1 and List2 that come from APIs set to List1 structure List as data type and List2 structure List as data type. And you create a new output variable with the data type set to FinalList structure List as the image below shows:

Now comes the logic. First you do a ListAppendAll to the FinalList and set the source list to List1. Since structures are not equal you have to map them. In this case i just want the Name and Price from List1 so the other 2 fields stay empty.

To finalize, you do a for each loop through the FinalList and inside it, you do a ListFilter where you filter through List2 for any records that have the same name (this is your common attribute) as the current FinalList record. This will return one record. After that, you do an assign to the Current FinalListCity and FinalListCountry and assign the Current FilterListCity and Current FilterListCountry. This should solve your problem as you now have a FinalList with columns from both lists.

Let me know if this solves your problem.

Best regards,

Lourenco Matalonga

2025-04-30 07-30-15
Sanjay Bankar

Hey @Lourenço Matalonga  

Thank you So much your solutions worked me perfectly.


Regards

Sanjay Bankar


2023-05-30 10-05-13
Lourenço Matalonga
2023-01-26 16-03-24
Ana Agostinho

Hello Sanjay Bankar, 

Merging one list into another is not possible when the structures of the lists are different. However, if the fields of one list can be mapped onto the fields of another, you can iterate over the second list using a "For Each" loop and use "ListAppend" to add each record, mapping the fields from the second list into the first list.

In cases where neither structure can accommodate the other list, my suggestion would be to create a new structure and a new list. Then, using a "For Each" loop, you can add each record to both lists using "ListAppend".

Best regards, 

Ana

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

The API which you are using might be returning some data, Is there any relationship between data,
IF yes then based on the data relation you can create another List and define a Custom Structure over there with a combination of cols you want to map with bith two API's,
Now just append the result to your structure.

Thanks

2025-04-30 07-30-15
Sanjay Bankar

Hello @Tousif Khan 


I am having Common attribute between Two Lists but i am not getting ho to interate...Can you Please explain or share oml?


Regards 

2023-05-30 10-05-13
Lourenço Matalonga
Solution

Hi @Sanjay Bankar ,

so if you are getting those two lists from an api  the output of those API is a record list. Ok, you have 2 different record lists and you want to have a final list that includes some columns from  List1 and some columns from List2. Then you will need to create a new structure with the attributes that you want one the final list. Something like this:


You have List1 and List2 that come from APIs set to List1 structure List as data type and List2 structure List as data type. And you create a new output variable with the data type set to FinalList structure List as the image below shows:

Now comes the logic. First you do a ListAppendAll to the FinalList and set the source list to List1. Since structures are not equal you have to map them. In this case i just want the Name and Price from List1 so the other 2 fields stay empty.

To finalize, you do a for each loop through the FinalList and inside it, you do a ListFilter where you filter through List2 for any records that have the same name (this is your common attribute) as the current FinalList record. This will return one record. After that, you do an assign to the Current FinalListCity and FinalListCountry and assign the Current FilterListCity and Current FilterListCountry. This should solve your problem as you now have a FinalList with columns from both lists.

Let me know if this solves your problem.

Best regards,

Lourenco Matalonga

2025-04-30 07-30-15
Sanjay Bankar

Hey @Lourenço Matalonga  

Thank you So much your solutions worked me perfectly.


Regards

Sanjay Bankar


2023-05-30 10-05-13
Lourenço Matalonga
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.