// ServiceNow

Holiday time check based on the schedule definition

Below is the code used to check the schedule data defined for SLAs from within the code and perform working-hours checks.

gs.log( isWorkTime() );

function isWorkTime() {
    var r = false;

    var schedule_sys_id = '08fcd0830a0a0b2600079f56b1adb9ae';

    var glide = new GlideRecord('cmn_schedule');
    glide.addQuery('sys_id', schedule_sys_id);
    glide.query();
    if (glide.next()) {
        var sched = new GlideSchedule(glide.sys_id);
        var date = new GlideDateTime();
        gs.info("AVT ScheduleName: " + sched.getName() + " NowDate: " + date.getDisplayValue());
        //date.setDisplayValue("2007-09-18 12:00:00");
        if (sched.isInSchedule(date)) {
            gs.info("Mesai saati içinde !");
            r = true;
        } else {
            gs.info("Tatil");
            r = false;
        }
    }
    return r;
}

 

// FEEDBACK

Was this useful?

Your rating shows how helpful this note is to other readers.

Was this useful?

Click the stars to rate.

Average rating 0 / 5. Total votes: 0

No one has rated this post yet. Be the first!

Sorry this post was not helpful.

Your feedback is valuable to us.

How can we make this post more helpful?

// JOIN THE CONVERSATION

Share your experience

Got a question, a different solution or a note to add?

// KEEP READING

One more note.

All posts ↗︎