Skip to main content

Preventing Double-Booking of Calendar Events

  • Chapter
  • First Online:
Creating Business Applications with Office 365
  • 1350 Accesses

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 to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 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. 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. 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. 5.

    Feel free to skip this next part if how this all works is not of great interest.

  6. 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. 7.

    See https://msdn.microsoft.com/en-us/library/office/ms467521.aspx for details on CAML.

  8. 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

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Jeffrey M. Rhodes

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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

Publish with us

Policies and ethics