Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 08:13 PM - edited 10-12-2024 09:36 PM
From a script include perspective, I'm lost on how to do that (or it's just not coming to me at the moment.) This is the script include I have.
var DateValidator = Class.create();
DateValidator.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateDate: function() {
var selectedDateStr = this.getParameter('selectedDate'); // Get date from the client
var selectedDate = new GlideDateTime(); // Convert to GlideDateTime
var output = this._checkHoliday(selectedDateStr, "8-5 weekdays excluding holidays");
//gs.info("DateValidator: " + selectedDateStr + " Holiday is: " + output );
return output;
},
_checkHoliday: function(myDateTime, scheduleName) {
var blockedDay = false; // initalize holiday to false
var schedule = new GlideRecord('cmn_schedule');
schedule.addQuery('name', '8-5 weekdays excluding holidays');
schedule.query();
if (schedule.next()) {
var sched = new GlideSchedule(schedule.sys_id);
var d = new GlideDateTime();
d.setDisplayValue(myDateTime); // setting myDateTime
if (sched.isInSchedule(d))
blockedDay = false; // not a holiday or weekend
else
blockedDay = true; // holiday or weekend
}
return blockedDay;
},
});