how to set up a job condition to exclude holidays?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 06:54 AM
Hello everyone!
I tried this script, but it returns false
var answer = new GlideSchedule("sys_id").isInSchedule(new GlideDateTime());
gs.log(answer);
type exclude
I need the schedule job not to work on holidays
how can i do it?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 07:20 AM - edited 12-30-2022 07:21 AM
Hi @Marina15
Please use the below script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 07:25 AM
you misunderstood me, Saturday and Sunday have nothing to do with it, it’s the holidays from the calendar, the cmn_schedule table. if I change the holiday type to any other, everything works, but with the "Exclude" type it doesn't work. And I need to write a condition for schedule job based on these holidays.
scheduled job creates an event every day, to which the notification reacts and is sent. I don't need notifications to be sent on holidays
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 07:51 AM
@Marina15 Please try below code. This should work for you.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 07:59 AM
I still think that the reason is the exclude type, because the same thing that I have in the code, only with a different type of holiday, works as expected