Loop though a list to generate an email based on a column variable

  • 22 November 2017
  • 8 replies
  • 9 views

Badge +6

I'm in need of expertise and guidance with creating a workflow that will loop though a list of data and trigger an email based on a column variable within that list.

My list has several columns of data which one of them is the Date that an associate completed and submitted the required Nintex form. I then created a column called Time Duration that basically just calculates the days from current/today's date and when the form was submitted. The email notifications I need to send will be triggered on the Time Duration info if over 12 months (or greater than 365).

So what I need is to loop though this list (our team wants this to run weekly) and generate a notification email. However, I have not built a workflow loop and this is where I am in need of guidance.

I have seem some posts that are using Web Services and some that are using multiple workflows, but those each don't quite fit what I am looking to do.


8 replies

Badge +11

Hi Jeremy,

this would be my approach:

List-Workflow

   1. Create a new Workflow on your list that sends out the required mail.

Site-Workflow

  1. Create a new site workflow
  2. Use a "Calculate Date" action to caluclate the Date u need (Current Date - 12 Months/365Days)
  3. Use a "Query List" action to get all relevant Item-IDs from the list. You should use the filter function inside this action to only receive the items you want to send an email for (Get item if "Created" is smaller than the calculted date form 2.). The result will be an amount of IDs you need to save inside a variable of type "collection"
  4. Use a "Foreach" action to loop through your result-collection from 3. and start the new created list workflow to send out the mail
  5. For starting the List-Workflow you should use a "Call Webservice action" and use the Nintex Webservices "StartWorkflowOnListItem"-Method (this should get you started:Start a Workflow using a Web Service )
  6. Schedule your site workflow to run once a week (possible via the gear menu on the top of your page -> Nintex Workflow -> Schedule Site Workflow)

Thats about it. You could now throw away your calculated "Time Duration" column as the calculation is done via the site workflow. Besides calculated columns are not the right thing to use here as their value is only updated if the item is edited.

Cheers

Philipp

Badge +6

Thanks Philipp.

As I am completing the Query List, there is a required section (Field) under the last item "Sort". Wasn't sure what the appropriate selection here would be. Any thoughts?

Userlevel 3
Badge +12

Hi,

From Phillips reply, you can use "send email" workflow action within the site workflow itself, no need to create a list workflow and call is using web service" action.

And you can select a "Field" that you want to use it in your email notification, like "use who created that item" or any other fields.

Badge +6

I have a good handling on the email part of the workflow. The field that I am referring to is below. The Query List action will not work unless this required Field has a selection. Just not sure what I should select from the drop down.

Userlevel 3
Badge +12

Well, it depends on your requirement:.

1. If you want to send email to the user who created that item, you can select "Created By" and use this field value to send email notification.

2. If you want to send the item details like "Title" in the email notification, select "Title"

3. If you don't want to send any list information in the email notification, just select any field and ignore i.e. do not use anywhere in the workflow.

Badge +6

Awesome. Appreciate the insights.

Badge +6

Would you be able to make the steps provided more visual? I am building the workflow and need some assistance on what this should really look like. I feel like that I have some of the steps in the wrong place/order and/or not having the right steps with the loop.

Thanks.

Badge +6

The final version of this can be found at List workflow - query list and email.

Reply