- 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-08-2020 03:13 AM
Hi,
gs.nowDateTime() returns a string where as isInSchedule requires a date/time as arugment.
So use gdt in place of a in the if condition and your code shall work.
Kindly mark the comment as helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2020 03:23 AM
Hello Asif,
I have updates as said by you and tried but still Schedule Job was getting triggered. Below is the code which i have used.
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981");
var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714");
var a = gs.nowDateTime();
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() > 1 || gdt.getDayOfWeek() < 5){
if(s.isInSchedule(a)&&!w.isInSchedule(gdt)){
answer = true;
}
answer = false;
}
answer = false;
Thanks & Regards,
S.Swaroop.

- 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-08-2020 03:55 AM
Hello Asif,
It worked perfectly. Thank you for the help.
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2020 02:49 AM
Hi Swaroop,
As said by asif please try adding log and check if you get 8 or 7 May
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader