how to set up a job condition to exclude holidays?

Marina15
Tera Expert

Hello everyone! 

I tried this script, but it returns false

var answer = new GlideSchedule("sys_id").isInSchedule(new GlideDateTime());
gs.log(answer);

 

Marina15_0-1672411983887.png

type exclude

 

I need the schedule job not to work on holidays
how can i do it?

Thanks in advance!

13 REPLIES 13

@Marina15 Tried and Tested solution.

 

var sched = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae");
var date = new GlideDateTime(new GlideDate+" 10:00:00");
var answer = sched.isInSchedule(date);
gs.info(answer);
 
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

it still returns false because holiday type is exluded, if i change it to any other it will return true but i can't change

@Marina15 for holiday it should show false, that's correct right.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

the problem is that if i add 5 days and it's no longer a holiday, it still returns false