Exclude Custom Holiday Shedule when calculating End Date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 05:55 AM
Hello All:
I have a need to exclude our corporate Holiday schedule from an HR process.
The Process = A specific group of 60+/- people are required to take 5 consecutive business days off each year.
HR needs to have their access to any/all corporate programs/resources terminated during that time.
I've successfully accounted for Weekends in my script (below):
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var cdt = g_form.getValue('start_date');
var addtime = '';
var addtype = 'day';
var myGDT = new Date(cdt);
if (myGDT.getDay() == 1) {
addtime = 5;
} else {
addtime = 7
}
var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name', 'addDateTimeAmount');
ajax.addParam('sysparm_fdt', cdt);
ajax.addParam('sysparm_addtime', addtime);
ajax.addParam('sysparm_addtype', addtype);
ajax.getXML(doSomething);
}
function doSomething(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//You could then take the new Date/Time answer and set the value of another field.
var myDate = answer.slice(0, 10); //10/05/2022 24
g_form.setValue('end_date', myDate);
g_form.setValue('control_end_date', myDate);
//alert(myDate);
}
Now, based on a users oversight, I need to take into account the Corporate Holiday schedule. I have 4 different schedules, so I can't use the OOB Exclude Holiday/Weekends schedule.
I've seen other posts, but they don't seem to fit. Any recommendations?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 06:38 AM
Could not this be achieved code-less via SLA definition on a selected table, using the Schedule (e.g. 9-6 weekdays excluding holidays) and having the days off defined on that record?
PS: this might be challenging if it is not regularly repeated in the same date every year (similarly to Easter, a little different dates every year), but you can create the records for years ahead if known.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 05:53 AM - edited 10-16-2024 05:54 AM
I have a "Schedule" entered for the Custom Dates. Yes I understand it's tricky, since several of the holidays are not "Standard" like Easter, New Years, 4th of July.... I'm planning on having these entry updated by an API Call when new schedules are made available.
I've never used an SLA definition to control dates on a Catalog Item.
Could you explain?
THe catalog item documents Required Time off and creates several tickets for Manual Deactivation/Reactivation.
So any help you can provide will be appreciated.