Abstract
The genesis of this chapter was a request by our Registrar for a solution so that cadets scheduling tutor appointments would be prevented from trying to book an appointment that overlaps another tutoring session. Each tutor has his or her own SharePoint calendar. They had a solution in our previous SharePoint 2010 version, but that involved “Resource Reservations” and was deprecated in SharePoint 2013. I found some references to a JavaScript/jQuery solution, which as you can probably already tell were much more up my alley. In this solution, we check any existing regular or recurring appointments before accepting a new or edited appointment. If the new or edited appointment overlaps an existing appointment, the user is shown a message and the appointment does not go through. Note that this approach checks against existing recurring appointment but does NOT check a new recurring appointment against conflicts. So new recurring events could overlap either other recurring appointments or existing regular appointments.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
This solution also prevents appointments being scheduled when the tutor is on vacation or otherwise out of the office, assuming those events are added in the calendar.
- 2.
It is possible to change the name of these forms in Designer. You can go to Lists and Libraries, click the name of the calendar, and then look at the Forms area of the page to see if the names of the Edit or New forms have a different name.
- 3.
The recurring appointments cause some extra work as described in the following, but the additional effort is worth it because recurring events like staff meetings, lunch times, and workouts are very common.
- 4.
We will see in the following code that we needed to account for different time zones. This came out when my initial solution worked in Internet Explorer but not Chrome.
- 5.
Feel free to skip this next part if how this all works is not of great interest.
- 6.
You might notice this line in formatHours: var returnHours = (hoursArray[0] - 0);. This is a common technique to account for the fact that JavaScript does not have defined types like number or string. To ensure that the browser interprets returnHours as a number, we subtract 0 from it. Otherwise, we can get situations where a line like returnHours + 12 would give a value like “512” rather than 17.
- 7.
See https://msdn.microsoft.com/en-us/library/office/ms467521.aspx for details on CAML.
- 8.
The main reason that I’ve found for it NOT to return success is when the end user renames the calendar without changing the checkDoubleBook.js file. That’s why the error message displays the expected name of the calendar and asks to check if it has been renamed.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2019 Jeffrey M. Rhodes
About this chapter
Cite this chapter
Rhodes, J.M. (2019). Preventing Double-Booking of Calendar Events. In: Creating Business Applications with Office 365. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5331-1_7
Download citation
DOI: https://doi.org/10.1007/978-1-4842-5331-1_7
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-5330-4
Online ISBN: 978-1-4842-5331-1
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books