How to send an email to an individual after querying a list and for each loop

  • 8 February 2017
  • 6 replies
  • 7 views

Userlevel 3
Badge +8

All,

Slowly but surely learning Nintex forms and Nitex workflow.

I have a site workflow. The workflow is going to have to be scheduled.

It's first action is to query a list and collect various other fields:

198487_pastedImage_1.png

I have a For Each loop

198488_pastedImage_2.png

With 2 collection operations:

198489_pastedImage_3.png

The end of my workflow has a send notification action.

The send notification sends an email to a named individual, yet how or where do I add another query list (?) or another action to specify that within the email I only want to show items which the named individual is named in the To field and

not all list items which was originally queried.

The named individual isn't necessarily known until the list has been queried, so I can't filter on the first list query.

Thanks

Andrew


6 replies

Userlevel 3
Badge +9

I'm assuming you're trying to group all the entries from the list you're querying based on a person assigned to them, and then send a single email with all of those related items in the body of the email.  To accomplish this, you would need to have a loop within a loop.  The 2nd loop would need to do the work of collecting only those entries that belong to the person you're sending the notification to.  Assuming one of the fields you're pulling back from the first query is the person the notification goes to, I would sort the results from that query list by the person name.  Then in the second loop you can set a condition for it to run as long as the person for the current item equals the person for the previous item.  You would collect those records in a variable.  Once the names don't equal, that's your trigger to send the notification to the person with the records that belong to them, then start the process again for the new person.  

Userlevel 3
Badge +8

Brendan et al.

I'm almost there. My workflow looks as the pictures below. Looking at my verbose logging. The forEach loop is working and filtering my list by whom an item is assigned to. The "collection" send notification action is showing the correct results. i.e. all my collection variables are working and the email is going to the correct person(s).

Yet, my final email outside of the loop is only going to one person and not everybody in an assigned to collection.

Any thoughts ?

Thanks

Andrew

1

Userlevel 3
Badge +9

How is that notification configured?  If you're using a variable in the Send To field, how is that variable being set up?  Without seeing the details it's hard to advise where the problem may be. 

Userlevel 3
Badge +9

Could you post an export of your workflow?  That may be the easiest.

Userlevel 3
Badge +8

Sorry didn't see reply Export attached.

Userlevel 3
Badge +8

This has annoyed me for a long time, but finally cracked it.

Recap: filter SP list (columns:id,title, assigned to etc.) and send an individual user an email with a list of items where they are the person named in the assigned to column.

Finished workflow is as simple as:

The 1st query list action :

The collection operator

For each

The 2nd query list (inside of the for each loop)

Note the 2nd ID Collection variable.

Send to action

Variables

Reply