Nintex Workflow – Scheduling a Workflow at the End of the Month

If you schedule a Nintex Workflow on the last day of the month and set it to run monthly, you’ll find that on the following month, it will probably not run on the last day.  That is because it currently adds 30 days to current date and that’s the next schedule.

For some people, that’s not what they need.  They actually need it to run on the last day of the month and some specific time (eg. 6pm).

Here is the solution that I have created for this.

Requirements

These are the requirements needed for my workflow (that you can download with the link at then end of this post), to run successfully.

  1. Workflow Constant (text) : NW DB Connection String
  2. Workflow Constant (credential) : Farm Admin Credential

The “NW DB Connection String” is simply the connection string you can get from Central Administration > Nintex Workflow Management > Database setup The “Farm Admin Credential” constant is the credentials that will be used in the web service calls in the workflow.

Workflow Pseudo-Code

Get the next months last day

  This can be done with a SQL Call

The result is the last day but the time is 11:59:59PM

  Perform a date calculation, subtracting the appropriate hours and minutes to get the time we want

Make a Web Service Call to the Nintex Workflow web service, to remove the current scheduled on this list item

Make a 2nd Web Service Call to add a new workflow schedule on this item

Workflow

The SQL query looks like this:

SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0))

You store the result in a DateTime variable.

Execute SQL

This will give us the date of the next months last day.

Now, what we want is for our workflow run at 6pm.  Since the datetime returned has a time of 11:59:59PM, we’ll subtract 5 hours and 59 minutes.

Calculate Date

In our dtResult datetime variable, we should now have the last day of next month and have it set to 6pm.

Finally, this workflow will be run on a schedule, so we want to remove the current schedule using a web service call before we add a new schedule to the current item.

Remove Existing Workflow Schedule

Now, we can add the new workflow schedule and we should be good to go.

Add New Workflow Schedule

Downloads

Nintex Workflow 2010 : v2.3.5.0

Download the Get Next Last Day of the Month Workflow

Leave a Reply

Your email address will not be published. Required fields are marked *