Defining Custom Holidays

by David Goldfarb Updated Jul 18, 2019

Onit’s Holiday Provider App allows you to specify which days on a calendar should be considered “holidays” when executing Liquid-based date math. When a Holiday Provider App is created and configured, Onit’s add_business_days filter can exclude holidays that you define. Each holiday is represented by an individual Record in the Holiday Provider App.

Holiday Provider Configuration

As mentioned earlier, each holiday that you want to honor will be represented by an individual Record in a Holiday Provider App.

To get started, create a new App named Holiday Provider that contains the following Fields:

  1. holiday_date (date, required)  Specifies the date of the holiday. A required Field.
  2. calendar_name (combo, required)  Specifies which calendar the holiday should fall under. The values of the combo should represent specific calendars (e.g., 2019 US Holidays, 2020 US Holidays). For example, let’s say that you have an office in the United States and the United Kingdom. Some holidays, like Independence Day, should only be listed the US calendar, to prevent incorrect date calculation for your UK office.

Note: Even if your environment only has one calendar, the calendar_name Field is still required in the App and every Record in the App must have a value in this Field.

  1. active (checkbox)  Represents if the holiday is active or inactive. This checkbox should be given an initial value of true.
  1. In most cases, we recommend that you hide both the pre-created requester_name and requester_emails Fields, as they are not important to this configuration.
  2. Repurpose the pre-created name Field by changing its label to Holiday Name.

Next, perform the following set up tasks:

  1. From any App’s Advanced Designer sidebar, navigate to the Holiday Provider node.
  1. Click the Holiday Provider node and click the plus button to create a new provider.

Note: Only one provider can be active in an environment at any given time.

  1. Configure the new provider as follows:
  • Name: Enter a name for the provider. We recommend using simply Holiday Provider.
  • Apps: Select the App that you just created named Holiday Provider.

Note: Only one App can be selected here; selecting another App will clear all Fields in the configuration.

  • Holiday Date Mapping: Select Holiday Date (holiday_date). This identifies the Field in your App that will contain the date of the holiday.
  • Holiday Name Mapping: Select Holiday Name (name). This identifies the Field in your App that will contain the name of the holiday.
  • Calendar Name Mapping: Select Calendar Name (calendar_name). This identifies the Field in your App that will contain the date of the calendar that holiday lives within.
  • Active/Inactive Mapping: Select Active (active). This identifies the Field in your App that indicates whether or not a holiday is active. Note that this setting is optional: if you leave it blank, all holidays will be used whether set as active or not.

Note: Inactive holidays will be ignored when Liquid-based date math and conflict checks are performed.

  • Enabled?: Check this box to enable the provider.

Your Holiday Provider App is now fully set up! Before you can use it, be sure to create some Records in the App, each of which will represent holidays.

Below is a screenshot of a Dashboard for a Holiday App that contains a series of holiday Records.

Using a Holiday Provider in Liquid Date Calculations

Any of the following Liquid expressions will honor holidays defined in a Holiday Provider App:

For example, let’s say that you had a holiday of July 4, 2019 defined in your Holiday Provider App. Based on this holiday, you could run the following Liquid expression:

{% assign baseline_date = "2020-07-01" | to_date %}

{{ baseline_date | add_business_days: 25, “2020 US Holidays” }}

The outputted value would be 2020-08-05.

In this example, the arguments passed into the Liquid expression are as follows:

  • 7/1/2020 is the baseline date that you want to add to. This can be defined as a hard-coded date (as seen above), or via a date Field in an App, or view the now keyword.
  • 25 is the number of business days that you want to add to the baseline date.
  • 2020 US Holidays is the name of the calendar within which you want the Liquid expression to check.

Performing Lookups to Identify Holidays

You can designate the Holiday Provider App as a Transaction List Provider. Doing so allows you to perform list lookups into the Holiday Provider App to determine if any given date falls on a holiday. For example:

{% capture conflict_check %}

{{ event_date | date:"%m/%d/%Y" | list_lookup: 'Holiday Provider', 'holiday_date', 'name' }}

{% endcapture %}

{% if conflict_check != blank %}The date you have selected conflicts with {{conflict_check}}

{% break %}

{% else %}No conflict

{% endif %}

Note: When performing list lookups against holiday dates you must format date Fields using the date filter into the following format: “%m/%d/%Y”.

Previous Article How to Create a Sibling App Panel
Next Article Using the Panel Editor

© 2020 Onit, Inc.

docs.onit.com contains proprietary and confidential information owned by Onit, Inc. that is subject to copyright. Onit presents it exclusively to you for your sole use in conjunction with using Onit products. No portion of the materials contained herein may be used for any other purpose. No portion of the materials contained herein may be shared with third parties or reproduced in any form.