isInschedule is not working as expected and giving always false even though the date is correct

Aasrita
Tera Contributor

Hello All,

 

We are having a requirement to run a schedule job to send the auto strikes on incident. This schedule job should not run on german schedule and weekends. I have seen many articles to use isInschedule but it is always showing the result as false. Please let me know if we have another way to stop schedule job running from particular schedule.

Aasrita_1-1716367422653.png


Holidays we are inserting in schedule and checking

Aasrita_2-1716367498655.png

 

 

3 REPLIES 3

BillMartin
Mega Sage

Hi @Aasrita ,

 

Try testing this code for your guidance.

 

var glide = new GlideRecord('cmn_schedule');
glide.addQuery('type', 'blackout');
glide.query();
if (glide.next()) {
var sched = new GlideSchedule(glide.sys_id);
var date = new GlideDateTime();
date.setDisplayValue("2007-09-18 12:00:00");
if (sched.isInSchedule(date))
gs.info("Is in the schedule");
else
gs.info("Is NOT in the schedule");
}

 

You can find more details from the documentation

 

I suggest to get familiarize on the syntax.

 

Please mark as helpful and accept as solution if you find it helpful.

Hello Martin,

 

When i do this even the date is in schedule I'm just getting "Is NOT in Schedule"

Hi @Aasrita ,

 

the outcome is the correct behavior.

 

Thanks,

Bill