- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 11:24 PM
How to stop schedule job to trigger on Holidays. I have updated all holidays in Schedules.
Thanks & Regards,
S.Swaroop.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 03:37 AM
Okay.
I added few logs and made few changes. can you chck and share the output.
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981");
var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714");
var a = gs.nowDateTime();
var gdt = new GlideDateTime();
gs.log(gdt);
if(gdt.getDayOfWeek() > 1 || gdt.getDayOfWeek() < 5){
gs.log("Entered here 1");
if(s.isInSchedule(gdt)&&!w.isInSchedule(gdt)){
gs.log("Entered here 2");
answer = true;
} else {
gs.log("Entered into else of inSchedule condition");
answer = false;
}
} else {
gs.log("entered into else condition of week");
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 11:37 PM
Hi Swaroop,
So you have a schedule which has list of holidays; you will have to use condition in the scheduled job;
check if today falls in that schedule; give the schedule sys_id in the script below
conditional checkbox as true;
new GlideSchedule("schedule_sys_id").isInSchedule(new GlideDateTime());
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 11:43 PM
Hello Ankur,
I have a schedule job which will trigger on weekdays and between business hours. for that i have written a script,
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981");
var a = gs.nowDateTime();
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() > 1 || gdt.getDayOfWeek() < 5){
if(s.isInSchedule(a)){
answer = true;
}
}
But in that script i should write a condition like this schedule job shoudlnot trigger on holidays. how to configure that condition in the above script.
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 12:09 AM
Hi Swaroop,
What is your scheduled; is it Monday to Friday excluding weekends and holidays; if yes then you can just use this in script
Can you share your schedule screenshot
new GlideSchedule("schedule_sys_id").isInSchedule(new GlideDateTime());
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 12:27 AM
Hello Ankur,
I have two schedules
1) one is for Business hours.
2) another one is for holidays.
Requirement - Schedule job should trigger on weekdays and between business hours and it should not be a holiday on that day.
For that i have written the below script.
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981"); - For Business hours
var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714"); - For Holidays
var a = gs.nowDateTime();
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() > 1 || gdt.getDayOfWeek() < 5){
if(s.isInSchedule(a)&&!w.isInSchedule(a)){
answer = true;
}
}
But it was not working as expected.