need help with isinSchedule()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:46 AM
Hi Guys,
So I've been introduced to Schedules and have been working on it for last couple of days.
Here's the code am trying to run in a scheduled job that would submit a catalog item if the date in in schedule '8-5 weekdays excluding holidays'. Each time I pass a weekday or any day for that matter, it goes in the else clause. Any thoughts?
*******************
var schedRec = new GlideRecord('cmn_schedule'); | // Query table for schedule |
schedRec.get('name','8-5 weekdays excluding holidays'); | // Get the schedule name |
var sched = new GlideSchedule(schedRec.sys_id); | // Create variable schedule |
var schedTime = new GlideDateTime("09-14-2017 08:30:00"); | // Create variable with current date/time |
if (sched.isInSchedule(schedTime))
{
gs.log('In schedule');
}
else
{
gs.log('not in schedule');
}
********************
From what I have understood, here the date passed is a weekday and hence should print 'In schedule' in the logs. But its not. Kindly advise.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2017 08:47 PM
inbox me @: hvrdhn88@gmail.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2018 10:39 AM
For future adventurers, here is a script I use to help test schedules:
//Background Script - Schedule Test
(function() {
var schedule = new GlideSchedule('5afd4fae4fe92b00a2c3d0af0310c7f7');//Put Your Schedule sys_id here
gs.print('Schedule Name: '+schedule.getName());
gs.print('Valid Schedule: '+schedule.isValid()); //If this says false, your schedule isn't valid
var d = new GlideDateTime();
d.setDisplayValue("12-25-2018 08:30:00");
if(schedule.isInSchedule(d)){
gs.print('In Schedule: '+d);
}
else {
gs.print('Outside Schedule: '+d);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2018 11:21 AM
Thanks for sharing Mike!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2019 07:52 AM
Hey,
I'm getting false value in schedule.isValid(), do you know why ?
(function() {
var schedule = new GlideSchedule('55ebbbf15f002000b12e3572f2b47714');//Put Your Schedule sys_id here
gs.print('Schedule Name: '+schedule.getName());
gs.print('Valid Schedule: '+schedule.isValid()); //If this says false, your schedule isn't valid
var d = new GlideDateTime();
d.setDisplayValue("12-25-2018 08:30:00");
if(schedule.isInSchedule(d)){
gs.print('In Schedule: '+d);
}
else {
gs.print('Outside Schedule: '+d);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 01:16 PM
Did you find a solution to your issue? If yes, please remember to tag the correct answer and any that were helpful.