166
Views
6
Comments
Merging lists with different data structures

I have two lists with different structures i.e List1 has 10 columns and list2 has 20 columns,

What i want to do  is to append list2 to list1 one with a purpose of generating a CSV file.

Can anyone assist me with a solution?

2023-01-26 16-03-24
Ana Agostinho

Hello Nkosikhona Ndimande, 

Merging straightforward one list into another is not possible when the structures of the lists are different (which is your case). However, if the fields of one list can be mapped onto the fields of another (which seems your case), 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, or vice versa.

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".


You can check/look a similar example marked a solution in this post:

Best regards,

Ana

UserImage.jpg
Narendra Maheshwari

Hello Nkosikhona,

You can use ListAppendAll with list2 (having 20 columns) and mapped your fist list columns to it.

Let me know if you need more clarity on it.

 


2025-07-16 17-09-54
Nkosikhona Malibongwe Ndimande

Hi @Narendra Maheshwari


The list with 10 columns must be the first line of the csv file i want to generate and the records of the second list with 20 columns must come afterwards.

UserImage.jpg
Narendra Maheshwari

You can create a temporary list of type List2 and append your list1 and list2.

UserImage.jpg
Puja Rani

Hi ,

You can use for loop and List Insert for your used case. In for loop will be your list2, and in ListInsert action List will be your List1(where you want to append data of list2), in position bind it to length of list1, by this you will be able to insert your list2 data after the list1 data ends. Hope this helps.



UserImage.jpg
Narendra Maheshwari

Please check the attached Oml, I have created one server action and appended the list variables.

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