8-5 weekdays excluding holidays- Not excluding weekends properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 10:07 AM
Hello All,
I have a requirement where my lead time for change has 10 business days when risk is high. I have used OOB schedule " 8-5 weekdays excluding holidays" in scripts which used to complete my development. But i faced a issue like when my lead time is 10 business days for my risk high it is not excluding the second weekends which comes under my 10 business lead times calculation.
For eg: If change created today (10/10/2023) and my lead time is 10 business days then it should allow me to enter (10/23/2023) which is date which comes from 10 business days from (10/10/2023) excluding(14,15,21,22-weekends date which are excluded). But unfortunately my schedule is excluding only dates 14,15 and not excluding 21, 21 date for weekend which is not supposed to be.
Since it is not excluding 21, 22 dates it allows user to enter date (10/21/2023 or 10/22/2023) which is not the correct date as part of 10 business days calculation
Can anyone pls help me understand why this issue happens and help me to resolve it. Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 10:11 AM
Hi Perumal,
What is your script? can you please post it here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 03:12 AM
Hello Manoj,
I am sharing the code where we are using the Glide Schedule.
var chgStart = startDate || this.getParameter("sysparm_start_date"); //get start date from client side
var chgStartGDT = new GlideDateTime();
chgStartGDT.setDisplayValue(chgStart);
var leadTimeGDT = new GlideDateTime();
leadTimeGDT.addDays(leadTime);
var zoneName = session.getTimeZoneName();
var dur = new DurationCalculator();
dur.setSchedule('090eecae0a0a0b260077e1dfa71da828');
dur.calcScheduleDuration(chgStartGDT, leadTimeGDT);
var secs = dur.getSeconds();
var totalSecs = dur.getTotalSeconds();
Can u pls let me know your inputs on it. Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 08:06 PM - edited ‎10-11-2023 08:18 PM
Hi Perumal,
Where are trying to do this, is it for the service portal, your script seems to be of the widget?
Anyways, if you are using GlideSchedule
"isInSchedule" method would help you
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");
}
Source: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/c_GlideScheduleScopedAPI
Important: check your schedule if it is set repeating
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 03:13 AM - edited ‎10-11-2023 03:14 AM
Can u pls help on this