In Date variable I should select only 7 business days after dates and it should not allow to select any saturdays and sundays
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 08:17 PM
HI
I have created a new date variable, For this date varable i need validations like, I should select only 7 business days after dates and it not allow to select saturdays and sundays
Can any one help me on this.
Thanks
Prasad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 08:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 08:51 PM
Hi
This is helpfull for only restricting weekends, here i need to one more funtionality like users select only 7 business days after dates from current date.
Thanks,
Prasad.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 09:17 PM
Hi find the below script. Onchange client script and Script Include
Make sure variable names are correct as per yours
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var msg = 'Proposed date cannot be prior to 7 business days from Request Date';
var ga = new GlideAjax('ValidateNeededBy'); // SI name
ga.addParam('sysparm_name','validateDate'); //SI function
ga.addParam('sysparm_needed_by',newValue);
ga.getXML(callBack);
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
//Calculating 9 hour schedule to check 7 working days 24*7=168
if(parseInt(answer)>= 54){
g_form.hideFieldMsg('start_on'); // variable name
}
else{
g_form.hideFieldMsg('start_on');
g_form.showFieldMsg('start_on',msg,'error');
g_form.setValue('start_on','');
}
}
}
Script includes
validateDate: function(){
var dc = new DurationCalculator();
dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // this is the sys_id of 8-5 weekday schedule in the instance.
dc.setTimeZone('GMT');
var dur = dc.calcScheduleDuration(gs.now(),this.getParameter('sysparm_needed_by'))/3600;
return dur.toString();
},
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 07:35 AM
HI
I need to both functionalities for same field
1. It shoud not allow to select next 7 business days
2. It should not allow to select saturday and sunday any more
Thanks,
Prasad