
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 08:55 AM
We have a scheduled job that was created by the vendor. It runs every hour on incidents table. I has conditional check with the following script to prevent it to run on Saturday and Sunday.
//Apply only on Weekday
var dateVal = new Date();
var weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var day = weekday[dateVal.getDay()];
if( day != "Sunday" && day != "Saturday"){
answer = true;
}
Because this is an automated 3 strike rule and we have holidays that don't count towards are SLA we would also like to prevent the 3 strike rule from running on Holidays. How can I modify this script so that it also does not run on holidays?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:21 AM
You will have to run scheduled job based on schedule
check below
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:21 AM
You will have to run scheduled job based on schedule
check below
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 11:15 AM
Other then having to fix the logic in his if statement it seems to be working.
checkInSchedule();
function checkInSchedule(){
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('8-5 weekdays excluding holidays');
if(typeof GlideSchedule != 'undefined')
var sched = new GlideSchedule(schedRec.sys_id);
var inSched = sched.isInSchedule(new GlideDateTime());
if(inSched){
return true;
}
else{
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 12:41 AM
the holiday days shall be type "excluded" in the cmn_schedule table? and what does isInSchedule() returns then if the days are of type "excluded" in cmn_schedule?: my scenario is to run the job on every 11th business day of a month, it should check the condition if there is a UK holiday it must exclude it as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 11:21 AM
You can fix the condition like this
//Apply only on Weekday
var dateVal = new DateTime();
if(dateVal.getDayOfWeek() <=5) {
return true;
} else {
return false;
}
Hope this helps.