How to Manage Holidays

It can be desirable to prevent due dates, SLA dates, and requested completion dates from being assigned on a day that is a company holiday. This can be accomplished within the service when the date is selected or within the workflow when due dates or SLA dates are determined (or both). To accomplish this though, there must be a record of what days are holidays.

While there are a number of different JavaScript libraries and ruby gems that support various sets of holidays, these are not the recommended manner of handling holidays. There are several reasons for this. First, this requires handling front and back end holiday managing seperately with seperate libraries which may have a different list of holidays, leading to inconsistency and rework. Secondly, these are generic list of holidays and may not match the days your company provides as vacation/time-off.

To provide the best results, it is recommended that you create a datastore to store your actual company holidays. This can be as simple as this example datastore (which uses this bridge model/mapping), or as complicated as necessary. You may need to store country or region if different locations of the company take different holidays, for example.

You can then use this same source to process dates in the form and in the workflow. For the example datastore, that would look like:


This is the code included in the event:

if (resource != null) {
$('#dateHandling').html("You cannot select a company holiday."); 
 K('field[Requested Date]').value('');
} else {

Essentially, in this example if the bridge does return a holiday, we want to show a message and remove the date. Otherwise we remove any message that might be present. There are other ways to display messages, including the Notifie Library, but this method was chosen for minimal dependency. This example item will work with the datastore and models/mappings in this article.