Skip to main content
Nintex Community Menu Bar

Here is one approach to creating a holiday booking workflow that excludes weekends and bank holidays. The logic of this workflow is based on creating a collection variable containing the date range of the requested holiday dates, a collection containing the bank holidays and then checking these dates against each other to filter out the bank holidays. The key to this working is enforcing the date formats throughout the workflow.

 

STEP 1: Create a custom list called HolidayBooking with 2 date columns for DateStart and DateEnd. The end user will use the DateStart and DateEnd to define the duration of their holiday.

 

 

STEP 2: Create a list workflow on the HolidayBooking list with the following variables:

 

3_WorkflowVariables.png

 

 

STEP 3: Create a collection called varColBankHol containing the bank holiday dates. These dates will eventually be excluded from the requested date range.

 

  • Regular Expression:
    • Pattern: ;
    • Operation: Split
    • Input text: Add bank holiday dates separated with semi-colons ";". Ensure there is no semi-colon at the end of the string as per screenshot below.]
    • Store results in: varColBankHol

 

185427_pastedImage_2.png

 

 

Example:

The Bank Holiday collection (varColBankHol) looks like this:

02/05/2016;30/05/2016;29/08/2016;26/12/2016;27/12/2016

 

 

STEP 4: Add the start date and end date as variables.

 

  • Set variable: varDateStart = StartDate
  • Set variable: varDateEnd = EndDate

 

4_SetVariable.PNG

 

 

STEP 5: Create a collection called varColRequestedDates containing the range of requested holiday dates ensuring they are formatted as dd/MM/yyyy. After the loop add the end date to the varColRequestedDates collection.

 

  • Loop: until varDateStart = varDateEnd
  • Collection operation:
    • Target collection: varColRequestedDates
    • Action: Add
    • Value: fn-FormatDate(varDateStart, "dd/MM/yyyy")
  • Calculate date: varDateStart + 1 day
  • Collection operation:
    • Target collection: varColRequestedDates
    • Action: Add
    • Value: fn-FormatDate(varDateEnd, "dd/MM/yyyy")

 

 

7_LoopUntil.PNG

 

 

Example:

The resulting collection (varColRequestedDates) based on a start date of 27th May 2016 and an end date of 2nd June 2016:

27/05/2016;28/05/2016;29/05/2016;30/05/2016;31/05/2016;01/06/2016;02/06/2016;

We next need to filter out the weekends and bank holidays from this range. 28/05/2016 & 29/05/2016 are weekend dates and 30/05/2016 is a bank holiday.

 


STEP 6: Remove weekends from the varColRequestedDates collection of requested dates.

 

  • For each:
    • Target collection: varColRequestedDates
    • Store results in: varDate1
  • Run if:
    • Condition: If any value equals value

Value: fn-FormatDate(varDate1, "dddd")

does not begin with

S

  • Collection operation:
    • Target collection: varColBusDates
    • Action: Add
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")

 

185428_pastedImage_0.png

 

 

Example:

The resulting collection (varColBusDates) with the weekend dates removed:

27/05/2016;30/05/2016;31/05/2016;01/06/2016;02/06/2016;

We removed 28/05/2016 & 29/05/2016 from the collection.

 

 

STEP 7: Now we have a collection variable containing a range of dates that excludes weekends. We now need to exclude bank holidays.

 

  • For each:
    • Target collection: varColBusDates
    • Store results in: varDate1
    • Stop processing: varYNEndLoop
  • Collection operation:
    • Target collection: varColBankHol
    • Action: Exists
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")
    • Store results in: varYNExists
  • Run if:
    • Condition: If any value equals value

Workflow Data: varYNExists

equals

Value: Yes

  • Collection operation:
    • Target collection: varColBusDates
    • Action: Remove by value
    • Value: fn-FormatDate(varDate1, "dd/MM/yyyy")
  • Run if:
    • Condition: If any value equals value

Value: fn-FormatDate(varDate1, "dd/MM/yyyy")

equals

Value: fn-FormatDate(varDateEnd, "dd/MM/yyyy")

  • Set variable: varYNEndLoop = Yes

 

8.png

 

 

Example:

The resulting collection (varColBusDates) with the bank holiday dates removed:

27/05/2016;31/05/2016;01/06/2016;02/06/2016;

We removed 30/05/2016 from the collection.

 

 

We now have a collection of dates based on a date range specified by the user that excludes weekends and bank holidays.

 

Mitch

Mate, you are a legend! This is exactly what I've been looking for. I have no idea why this isn't available "out of the box" with Nintex - I see feature requests going back a couple of years asking for this.

Do you happen to have this available as a snippet at all to save time recreating it? Not a problem if you don't; just thought I'd ask.

Nigel


Thanks Nigel Hertz! Unfortunately no I don't have this as a snippet. I'd like to provide an export list and workflow when I have a spare moment.

Mitch


Hello,

very interesting!

are you experiencing long processing times in loading the collection Variable because of the minimum loop delay of 5 minutes?

Thanks,

Piero


Good solution.

I came up with a rather quick and dirty solution to the same problem using Excel Services.

Calculating a due date when i have "lag days" - Workflow Question

I don't like it because it relies on the Excel Service and the excel file and if either of these are down, it isn't going to work, but it's a really quick solution to a tricky problem that like most others, I'm surprised Nintex hasn't addressed.


We have safe looping disabled but our environment does lean towards the slow side anyway so processing this workflow can take a few minutes.


I cannot get the loop to add all dates since the DateStart.  The loop does not error but it is also empty. The collection operations after the loop to add the DateEnd works so my RequestingDates collection has one value.  Any ideas why the loop may not be working?


what is the variable used in step 5 for calculate date.


Reply