Docs
On this page
task2 min readApplication: Platform

Create a schedule

Create a schedule of working hours or holidays for SLAs and reminders, with scripts for the common patterns.

Create a schedule when SLAs or reminders must count only working hours, or must skip holidays. A schedule is a short script that builds working time or holidays, and it can include other schedules.

Before you begin

  • You need the administrator role.
  • Know the working days, hours and holidays to cover, and the schedules you want to include by name.
  • You need basic JavaScript. The script uses ScheduleManager, RangeGenerator and DateTime.

Steps

  1. In the Administration workspace, go to Scripting & automation → Jobs & generators → Schedules.

    The Scripting & automation module with Jobs & generators open and Schedules selected.
  2. Select New. Enter a Name that says what it covers, for example “Monday to Friday 9AM to 5PM, no public holidays”. Leave Number empty: it is set for you.

    The empty Create Schedule form, with Number read-only.
  3. Enter a Description and turn on Active.

  4. In Script, build the schedule. This script gives Monday to Friday, 9:00 to 17:00:

    ScheduleManager
        .create()
        .withGenerator(
            RangeGenerator(
                RangeGenerator.WORKDAY,
                {
                    startHour: 9,
                    endHour: 17
                }
            )
        );
    
  5. Select Create.

Result

The schedule appears in the Schedule field of SLA definitions and reminder generators. An SLA that uses it counts time only inside the schedule, so its clock stops outside working hours and on included holidays.

Variations

A WORKDAY generator covers Monday to Friday unless you list workDays. Use startTime and endTime as hour, minute and second for times that are not on the hour. Holiday lists hold fixed dates, so update them each year.

Holidays

Create holidays as a schedule of their own, for example “Core holidays 2027”:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.HOLIDAY,
            {
                holidays: [
                    DateTime([2027, DateTime.JANUARY, 1]),     // New Year's Day
                    DateTime([2027, DateTime.DECEMBER, 25]),   // Christmas Day
                    DateTime([2027, DateTime.DECEMBER, 26])    // Boxing Day
                ]
            }
        )
    );

Regional holidays on top of national ones

Add the regional dates and include the national schedule by name:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.HOLIDAY,
            {
                holidays: [
                    DateTime([2027, DateTime.NOVEMBER, 2])     // Regional holiday
                ]
            }
        )
    )
    .include('Core holidays 2027');

Working hours with holidays

Include a holiday schedule in a working-hours schedule. SLAs using it do not count time on those holidays:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.WORKDAY,
            {
                startHour: 9,
                endHour: 17
            }
        )
    )
    .include('Core holidays 2027');

Hours not on the hour

Monday to Friday, 9:45 to 16:20:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.WORKDAY,
            {
                startTime: [9, 45, 0],
                endTime: [16, 20, 0]
            }
        )
    );

Around the clock

Every day, all day, for work such as P1 incidents that runs regardless of time:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.WORKDAY,
            {
                startHour: 0,
                endHour: 24,
                workDays: [ DateTime.MONDAY, DateTime.TUESDAY, DateTime.WEDNESDAY, DateTime.THURSDAY, DateTime.FRIDAY, DateTime.SATURDAY, DateTime.SUNDAY ]
            }
        )
    );

Different hours on different days

Monday to Friday 9:00 to 17:00, and Saturday and Sunday 11:00 to 16:00:

ScheduleManager
    .create()
    .withGenerator(
        RangeGenerator(
            RangeGenerator.WORKDAY,
            {
                startHour: 9,
                endHour: 17
            }
        )
    )
    .withGenerator(
        RangeGenerator(
            RangeGenerator.WORKDAY,
            {
                startHour: 11,
                endHour: 16,
                workDays: [ DateTime.SATURDAY, DateTime.SUNDAY ]
            }
        )
    );
Last updated 3 December 2026commit 6777698daac5Chris Jones
Back to top