need help with isinSchedule()

sk87
Tera Contributor

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

15 REPLIES 15

Harsh Vardhan
Giga Patron

Hi



Please check the thread below.



Re: isInSchedule is not working as excepted


Harsh Vardhan
Giga Patron

Re: InSchedule() is not working as expected



please refer the above link this one will help you


sk87
Tera Contributor

Hi Harsh,



I did go through all the threads pertaining to schedules, but could not make the code work.


i tested the code and it's working in my PDI



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-16-2017 08:30:00");             // Create variable with current date/time


if (sched.isInSchedule(schedTime))


{


      gs.print('In schedule');


}


else


{


      gs.print('not in schedule');  


}



find_real_file.png




other scenario


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.print('In schedule');


}


else


{


      gs.print('not in schedule');  


}



find_real_file.png