cancel
Showing results for 
Search instead for 
Did you mean: 
shaneoss
Nintex Newbie

Check Calendar for Double Bookings

There seemed to be many ways to do this, but all adhoc and no complete solutions. So I present the following. Example in bottom screenshot.

In your Nintex Form (classic).

1. Define "StartTime" as the Client ID JavaScript variable name for the Start Time control.

2. Define "EndTime" as the Client ID JavaScript variable name for the End Time control.

3. (Optional) - Remove the Recurrence label and control from the form. If you don't, it will be hidden anyway.

4. Copy and paste the JavaScript code from the attachment into your favorite Text Editor like Notepad++. Edit the first line and change "Calendar" to the Title of your SharePoint Calendar that your checking for double bookings.

You can also update the Error Text value on the second line if you wish to change the default.

Note: This solution is working on the assumption that your region date format is dd/MM/yyyy. If you need to use MM/dd/yyyy, please un-comment Line 29 (remove leading 2 forward slashes). Then comment Lines 25 & 26 (add 2 forward slashes to the start of each line).

5. Copy and Paste the updated JavaScript into Custom JavaScript within Nintex Form Settings.

6. Save and Publish your form.

If there is an existing booking an error is displayed and the Save buttons are disabled. When a period is specified that doesn't already have a booking, the Save buttons are enabled again and the error is no longer displayed.

Example:

I have also expanded the solution to work with an additional column e.g. a resource like a Hot Desk. So if you have multiple Hot Desks or resources. It would validate that, that resource isn't booked already.

Enjoy! This one took a while to put together.

Reply
10 Replies
heget
Nintex Newbie

Re: Check Calendar for Double Bookings

Nice post thank you, but I guess this isn't function for 24hours date format. Only for 12 hours isn't it?

I tried several time without success. Any help with that? And one more question If I have on Button (Save) my own value it's OK?

0 Kudos
Reply
shaneoss
Nintex Newbie

Re: Check Calendar for Double Bookings

Hi heget‌,

It uses the date/time picker control, so not 24hr format. Just the value selected in your control. Also you can have any label applied to your save button.

What issues were you facing?

0 Kudos
Reply
Highlighted
heget
Nintex Newbie

Re: Check Calendar for Double Bookings

But for me this solution doesnt work.

In the code if you check  (hoursArray == AM) 12 etc.

But we use 24h region format so maybe this could be the reason ...

Or this is compatible for each "Local date/time" 12 or 24 format. ? Smiley Wink

0 Kudos
Reply
heget
Nintex Newbie

Re: Check Calendar for Double Bookings

So I've chcked in Mozilla debugger and get this error on opening form.

RangeError: invalid date NewForm.aspx:1504:19
GetISODateString https://URL/Lists/SPZ1/NewForm.aspx:1504:19
CheckDates https://URL/Lists/SPZ1/NewForm.aspx:1517:31
<anonymous>

 

var isoDate = new Date(fullDate.getTime() - (fullDate.getTimezoneOffset() * 60000)).toISOString();

 

Any help ?

0 Kudos
Reply
heget
Nintex Newbie

Re: Check Calendar for Double Bookings

So I've tested again on EN regional settings with format of date 01/01/1991 and timezone 12h. It works perfect, but there is problem when I change to 24h. format.

And also if is changed regional setting to another language because then you have date liek this 01. 01. 1991 and the script can't work anymore.

So is there any chance how to edit the script for working also with those regional settings ?

0 Kudos
Reply
Automation Master
Automation Master

Re: Check Calendar for Double Bookings

Hi @heget,

 

I've updated @shaneoss' script so that it works for dates with a spaces in their formatting.

 

i.jpg

 

 

 

there are several bugs in NINTEX code that cause NINTEX do not correctly works with date formats that include a space, or include (accidentally) one more space, or doesn't include a space but space is expected, or a different separator is used then expected, etc.,

PLENTY OF problem in date/time handling in nintex products, especially if you use other then EN/US locale.

unfortunatelly, NINTEX refuses to fix it!

 

may I ask you what exact locale do you use?

could you perharps log an incident with NINTEX support that you experience problems with these date formats?

if they had more incidents reported for the problem, they might, hopefully, took it a bit more seriously...

 

 

Reply
shaneoss
Nintex Newbie

Re: Check Calendar for Double Bookings

Thanks @emha! Smiley Happy

 

Sorry @heget missed your previous posts. Yes no consistency with dates and locales across the Nintex suite as emha has mentioned. Wish there was. Smiley Happy It would make coding custom Nintex solutions alot easier for the global audience where time/date formats were involved.

 

Any issues just lets us know.

Cheers,

Shane

0 Kudos
Reply
shaneoss
Nintex Newbie

Re: Check Calendar for Double Bookings

@heget check out @emha's modified version of my script. If your still having issues let me know and what locale your using. Then i'll update my to match mine and do some further testing.Thanks!

0 Kudos
Reply
bdupree
Nintex Newbie

Re: Check Calendar for Double Bookings

Hello, @shaneoss where in your modified code do you add the script to take into consideration the resources field and the start and end dates? What is that field named? What type of field is it? If the resources field allows the user to select resources 1, 2, and 3 and if someone has all 3 resources booked already it will throw an error if someone is trying to also book resource 1, 2, or 3 on the same date(s). Or is each resource a separately named field?

0 Kudos
Reply