- 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 01:46 AM
Hello Ankur,
Yes for testing purpose i have made 8th May as Holiday in my Schedules.
Thanks & Regards,
S.Swaroop.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:35 AM
Hello Swaroop,
add gs.log(gdt) and check if you are getting 8th May or 7th May. May be due to timezone, you might be getting 7th because of which the condition might be failing.
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 02:49 AM
Hello Asif,
I have used the gs.log and it was giving May 8th, which was the date i have used for testing.
Thanks & Regards,
S.Swaroop.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:54 AM
Hi,
Are you using variable a or gdt in your code?
if(!w.isInSchedule(a))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 03:04 AM
Hello Asif,
1) I am using the below code in Schedule Job under "Condition".
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981"); - This is for checking Business hours
var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714"); - This is for checking Holidays
var a = gs.nowDateTime(); - This i am using to get current Date and time and to validate weather it is coming under Business hours (or) not.
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() > 1 || gdt.getDayOfWeek() < 5){
if(s.isInSchedule(a)&&!w.isInSchedule(a)){
answer = true;
}
answer = false;
}
answer = false;
2) For Testing of current time, i have created a BR and used below script for testing.
var a = gs.nowDateTime();
gs.addInfoMessage(a);