How do you send one email for multiple list items


Badge +9

I saw the below post which comes close to what I want to achieve.  However, I want to send the entire Query List (10 columns) out as an email.

I tried a Query List and Send Notification only as part of my workflow.  The Query List when I execute it retrieves all 5 of my records as expected.  However, the email only displays one item from the list.  I have spent 2 hours researching this and it appears I may need to create a Collection variable, however I am very confused on why this is required ?  Do I need to create 10 Collection variables for my 10 columns...One post suggested a For Each, but what is the purpose of a For Each when I do not want to send out an email for each list item. 

I use Nintex with SharePoint 2013 Enterprise.

Thanks !

how do you send a single email for multiple list items?


15 replies

Userlevel 6
Badge +12

Hello David Busch​ -

You would not be using the For Each loop action on the list, but the collection that you queried from the list.

The query filters down to the items you want to target, then loop through that collection to get the pieces you want, build out strings that you want in the email, and then put it all together in a notification.

You may want to check out Repeating section as html table in mail and look into using XSLT as it may be more of what you are thinking.

Hope this helps!

Badge +9

Thanks Jesse..Can yo refer me to an example of how I loop thru a collection...in the query list do I need to create 10 collection variables for my 10 columns or do I only set a collection variable for the List ID.. thx !

David B

Badge +9

Do I need to create multiple collection variables (12) within the query list.  Or do I create 1 collection variable.  Still puzzled on how the collection variable works within the query filter collection and the required loop to retrieve the pieces.  If you have a URL that may show a similiar example that would be great.

Badge +9

After researching further can you confirm I need to do the following:

  1. Query Filter
  2. Collection Operations (I need 10 collection operations) for my 10 columns that I need for the email
  3. Build String
  4. Loop
  5. Notification

For the Loop is the condition where the Collection ID = ListID

Userlevel 6
Badge +12

You would need to create a collection variable for each.

For example, if you have a list with Title, Start Date, and End Date as your columns, and you want to query the list to get all items with a specific Start Date, you will need a collection variable for all columns you want to do something with. So, in your Query list action, you will filter the list based on your needs and grab each field need.

185437_pastedImage_3.png

We do this so that if there are multiple results, we can iterate through them and do something with that data.

Once you have the collection variables, you can use a For each loop and loop through each record to get to the specific items, like so:

185438_pastedImage_4.png

Here we look in the titleColl variable and store the next one (based on index) in title

185439_pastedImage_5.png

For Each title we get the Start Date and End Date in the index position from the StartDateColl and EndDateColl respectively.

185440_pastedImage_12.png

185441_pastedImage_13.png

Now that we have the specific data from the item, we can comprise an email that is specific to an item within the list we queried:

185442_pastedImage_14.png

Hope this helps!

Badge +9

This definitely helps.  One clarification I need though is in your original post you said I did not need a For Each ?  Also, mp lan is to send out one email daily to 1 person only.  The email will be a dump of all items in an Active status.  thanks !

Userlevel 6
Badge +12

Hello -

In my original post, I meant that you would not want to use a For Each loop to send the notification (like my example above). You will want to use a For Each loop to gather all your necessary variables, build your strings, and then create ONE notification after you have ran through the loop.

Sorry for the confusion, its been a long weekend!

Hope this helps!

Userlevel 6
Badge +12

Hello David Busch​ -

Yes you will need a collection variable for each column you want to get and use later, and then an "item_Variable" (what I call them happy.png) to store the individual variables.

I went ahead and made a quick site workflow to demo the following:

  • Query List
  • Collection Variables (how we store the list item's details)
  • For Each loop (how we get to the specific details for a specific item)
  • Build a string (to use in a notification later)
  • Sending a notification with ALL of the queried details

Workflow:

185451_pastedImage_1.png

Workflow Variables:

185452_pastedImage_2.png

Let me know how this goes for you, but you can create a new site workflow and then import my attachment to see how I hooked everything up.

Hope this helps!

Badge +9

Hi Jesse, I got it to work ! Thanks for your assist.  2 outstanding issues though.

1-How do I get a field to appear as a link in the document.  As an example I have an Issue field which in the SharePoint list is the "linked to item" field.  In short how do I get a link/URL to display in the email for the list item.

2-I have a field called Details which unfortunately in some cases is VERY detailed.  Is it it possible within Nintex to do a LEFT(Field,50) so I only display the first 50 characters or so ?

Thanks..I have learned a ton in a short time period.

Userlevel 6
Badge +12

Hello -

Glad to hear you got it working!

As for your outstanding issues:

1. In the Notification action, you can insert a link by clicking Editing Tools > Insert > Link

185491_pastedImage_3.png

It will prompt you for the address and the text to display like so:

185498_pastedImage_10.png

2. Yes you can trim out the text if you want. You can use fn-SubString(text to modify, position of the first character to retrieve, number of characters to retrieve) to accomplish this. That is located in the Inline functions when you insert a reference.

185499_pastedImage_14.png

I have not used PadLeft or PadRight, but I believe you would get similar results.

Hope this helps!

Make sure you mark your question as answered so others can quickly see how you did it when searching happy.png

Badge +9

Hi Jesse for the notification though I need each item that I retrieved from the Query Filter.  In my current Workflow I am displaying all Active items for a list.  Thus, if I have 5 items will the above method you explained display 5 Linked Items.  Below is what I have in the email, however, these fields are a result of building a string.  thx !

Issue ID

Assigned To

Status

URL/Linked Item

..................

....................

Userlevel 6
Badge +12

Hello -

Ok this is easy enough, just need a few more variables setup:

185514_pastedImage_0.png

In you Query list action, add another field to capture (ID):

185515_pastedImage_1.png

Next, add another branch in the the For Each loop (if you are running them in parallel) to get the itemID based on the index:

185516_pastedImage_5.png

185517_pastedImage_6.png

Next you will need to build the url (using Build string action). You will need to add in your specific list name:

{Common:WebUrl}/Lists/YOURLISTNAMEGOESHERE/editform.aspx?ID={WorkflowVariable:itemID}

185518_pastedImage_7.png

Last thing to do is add it to your email string:

185520_pastedImage_9.png

This will get you the URL directly to the edit form of the item. You could replace editform.aspx with dispform.aspx to have the user click into the display form for the item.

Hope this helps!

Badge

Hi All,

I am trying to do the same- send one email at the end of the week that contains all users registered for induction on a particular date.

I have managed to get the for Each loop working where I get X emails for X people registered- but I need to merge all these emails into one.

I'm guessing it's got to do with the build string action... would you mind sharing your settings for that action?

Thanks in advance.

Billie

Amendment to post: I found the answer here

https://community.nintex.com/thread/10038

Just needed to add my email string variable to the start of the build string.

Hope this helps someone.

Badge +4

We have a field called time keeper, how do we email distinct time keepers and also provide link to all items related to that time keeper?

Badge

Hello! Thank you for this answer, everything is explained clearly and works perfectly in my case. The only problem I have is with quering the list. On Sharepoint I have data in the format M/d/yyyy, e.g. 8/15/2017, without time. I wanted to compare it to Current Date, as in this example, however it didn't work, the query didn't give any results. In the notifications I receive I see that the data variable gives the results with time e.g. 8/15/2016 12:00 AM. It's always 12:00 AM, even though on Sharepoint it's without time (date only format). I was trying to change format of dates, both on Sharepoint and in Nintex, but it doesn't work. It seems that they cannot be compared. Any suggestions what to do? Is it a matter of some settings?

Thank you in advance.

Reply