Question

Merge Collections equivalent

  • 16 February 2023
  • 2 replies
  • 146 views

Badge +1

I’m just starting to learn Nintex on SP 2016 OP.  I’ve got a list that containing multiple columns pertaining to vehicles, their registration numbers, assigned drivers and; maintenance intervals.

I had no problem creating a workflow to notify drivers when their vehicles are coming due for inspections (although it seems to send duplicate notifications to at least some recipients).

My intent is to create a WF to send a consolidated list of vehicles along with their respective registration numbers and driver info, to the maintenance supervisors.

Using Query List, I’ve been able to gather the requisite data into collections (Vehicle type, registration, driver info) however the only way I can get this info to display in the email notification is   

∑ Vehicle type,

∑ Vehicle Registration etc.

What I aim to achieve are individual lines that are easily interpreted such ie.

Vehicle 1 type, Registration #1, Driver #1

Vehicle 2 type, Registration #2, Driver #2 etc

It seems to me that Merge Collections would be perfect for this application, alas I haven’t got that option. I haven’t had any luck with converting the query returns into strings, but I’m still learning.

Any advice is much appreciated.


2 replies

Userlevel 5
Badge +14

This should be pretty straight forward with the Collection, For Each Loop, and Build String actions. 

 

Here is an example list of some items:

 

I’m going to make a new Workflow, and create the Following variables:

 

Notice the Type of each variable! 

 

Inside of a Query List Action I will point to the List, and grab both the Title and Price for, in my case, all of the Items. You’ll likely filter your own results in some meaningful way:

 

Because this is all from the same query, I know that what I’m getting back will be two collections containing the same Qty of entries. Because the entries are also ordered in the same way, then I know that the first item in the Title_Collection will be “Apple” and likewise the first Price in the Price_Collection will be “1.50”, just like how it is on the list itself.

 

Now comes the part where I actually need to extract those values out of the collection so that I can use them, so I will use a For Each Action configured like so:

 

What this does is tell the Workflow to Loop through each entry of a given collection. In this case the collection will be the one stored in the variable: var_Title_Collection. Every loop the value of whichever entry you’re on will be stored as a result in the variable of your choice. In this case I’m storing the result in the “var_Title” variable. Lastly, and though it’s technically optional, in this case you’ll need to assign a variable to hold the current Index of where you’re at in the loop. For Collections, the first entry is assigned to Index 0, and goes up by 1 from there.

 

If I were to write out a table to show the contents of our two Collection variables and the indexes of the values. it would look something like this:

 

var_Title_Collection

Title Index
Apple 0
Apricot

1

Avocado 2
Blackberry 3
Boysenberry 4
Jujube 5
Kumquat 6
Pear 7
Plum 8
Satsuma 9

 

var_Price_Collection

Price Index
1.50 0
2.00 1
3.00 2
4.00 3
5.00 4
6.00 5
7.00 6
8.00 7
9.00 8
10.00 9

 

As you can see there is a clear relationship to the Index and the position across both Collections. Knowing this, we can use our Index value as a means to get the correct information out of our var_Price_Collection using a Collection Operation Action:

 

Now that we are assigning a value to both the var_Title and var_Price variables, we can create a new Build String action and configure it to be recursive:

 

Notice how I start the buildstring with a reference to the same variable that we’re saving the result to. This means that every time we loop through our collection and add something, we’re adding it to the BOTTOM of all of the text that’s already stored in the var_TextBlock variable!

 

In the end our entire workflow looks like this:

 

Last but not least we can use a Send Notification action to send ourselves the results and see if we’ve hit the mark:

 

 

 

Looks Good!:

 

 

Let me know if this helps you on your way! 

Badge +1

Thank you very much.  Very clear and concise.  I look forward to trying this out!

Reply