Skip to main content
Nintex Community Menu Bar

Merge 2 collections of data into a single collection

  • November 8, 2019
  • 3 replies
  • 81 views

Forum|alt.badge.img+1

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? 

3 replies

Simon Muntz
Nintex Partner
Forum|alt.badge.img+23
  • Nintex Partner
  • November 10, 2019

Hi,

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

The workflow would look like this.

5516iD91B126934B68FB6.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.

 


Forum|alt.badge.img+1
  • Author
  • November 11, 2019

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.


Forum|alt.badge.img+12
  • Scholar
  • November 12, 2019

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