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-14-2017 11:06 AM
try below code and change sys_id to your schedule sys_id
var schedRec = new GlideSchedule('9f76b9cb37d36a005a0a2863b3990eff','US/Pacific');
var d = new GlideDateTime();
d.setDisplayValue("09-14-2017 08:30:00");
// Get the schedule name
var sched = new GlideSchedule(schedRec.sys_id);
if (sched.isInSchedule(d)
{
gs.log('In schedule');
}
else
{
gs.log('not in schedule');
}
EDIT: corrected syntax.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 11:12 AM
this is might be happening with the time zone that you have selected in "8-5 weekdays excluding holidays" schedule. when i change it to floating then it is working and if i change it to some randomly canada/pacific time zone then it's returning also else part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 11:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 08:11 PM
are you testing it in your PDI? if yes then i can have look
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2017 08:45 PM
Hi Harsh..sure... you can... let me know when you are available..