isInschedule is not working as expected and giving always false even though the date is correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 01:45 AM
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.
Holidays we are inserting in schedule and checking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 01:08 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 02:17 AM
Hello Martin,
When i do this even the date is in schedule I'm just getting "Is NOT in Schedule"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 03:09 AM