cancel
Showing results for 
Search instead for 
Did you mean: 
jraffe
Nintex Newbie

Merge 2 collections of data into a single collection

Jump to solution

I have two collections of data that I get from a query list action.

The first is a list of names:

Collection 1

person1

person2

person3

The second is a list of dates that the people in the first list will be on vacation for:

Collection 2

11-05-19

11-16-19

12-15-19

I want my list to look like this:

person1 - 11-05-19

person2 - 11-16-19

person3 - 12-15-19

but I cant seem to find a way to do that in Nintex.

 

In a programming language, all I would need to do is loop through one list and concatenate the current index items from both lists:

 

for(int i=0; i<collection1.size; i++){

     merged_list[i] = collection1[i] + collection2[i]

     i++;

}

Any suggestions? 

Labels: (1)
0 Kudos
Reply
3 Replies
Nintex Employee
Nintex Employee

Re: Merge 2 collections of data into a single collection

Jump to solution

Hi,

Its just a matter of retrieving the same index from both collections and then merging them.

The workflow would look like this.

POCMerge.png

 

I have attached a sample workflow which merges the entries from two collections and logs them to the history list. You can ignore the start of the workflow as I am just constructing my test collections and then counting how many items there are. As you can see the workflow design is just like the code in your post.

 

Reply
jraffe
Nintex Newbie

Re: Merge 2 collections of data into a single collection

Jump to solution

Thanks @SimonMuntz! I was close but could'nt get past the last part of the issue. I appreciate the step by step, very helpful and worked like a charm.

0 Kudos
Reply
Automation Master
Automation Master

Re: Merge 2 collections of data into a single collection

Jump to solution

@SimonMuntz ....I won't recomment loop action because of Safe Looping.

 

@jraffe ....Are collection 1 and 2 coming from same list? 

 

If Yes then:

  1. Using QL, get 2 collections i.e. collec_People, collec_Dates
  2. Now using For each, use collec_People and store it in slt_each_Person and also store the index in num_Index (default should be 0)
  3. In For loop, add collection operation and using collec_Dates and num_Index, get dt_each_Date
  4. Using build string add w/fvariable:slt_each_Person - w/fvariable:dt_each_Date

If No then:

  1. All the steps are same as it's for Yes (instead of 1 QL you'll need 2 QL for 2 different lists) and 1 additional step to increment the index value to +1. That's why @SimonMuntz  is using the Math Operation.
Reply