start date should be today + 2 business days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 08:51 PM
Posting this again as I could not get it working:
Hi
Can someone please help me with catalog client script (on change) and script include
I have a date variable in the new hire form.
The requirement is users should only be allowed to select the "start date" as current date + 2 business days (exclude sat-sun).
Example: If I'm filling the form today , (Oct 11) the start date should be Oct 14 or further. User should not be be able to select an ealier date and should give an error " Invalid date"
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:12 AM
Hi Ankur,
I still could not get the weekend thing working. I'm kinda overwhelmed with all the responses I've got, so far it has not worked. Hope you could help me fix my script.
Here is my catalog client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:31 AM
Hi @Thomas99
You should calculate the duration based on a schedule to get the business duration. Try the below script in script include.
var ValidateDate = Class.create();
ValidateDate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
dateValidation: function(){
var selected_date = new GlideDateTime(this.getParameter('sysparm_date');
var today = new GlideDateTime();
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(today, selected_date);
var days = duration.getRoundedDayPart();
if(days > 2){
return 'true';
}
return 'false';
},
type: 'ValidateDate'
});
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 05:48 AM
That did not work 😞
I had a syntax error on below line
I have also validated the sysID of the schedule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 05:08 AM
could you please look at my script include? I dont seem to get it working 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:10 PM - edited 10-10-2023 10:14 PM
You can try it by creating onChange catalog client script :
Note : in condition please mention (dayDiff < 2.0) instead of (dayDiff < 7.0)
Mark helpful & correct if applicable.
Thanks & Regards,
Sayali Gurav