Restrict public holidays and weekends from being selected in a form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 02:49 AM
Hi all,
I'm having issues with restricting public holidays and weekends be selected in a portal form.
I have created a script include and a catalog client script, code below.
Script Include:
The commented out part is something else I was trying.
Client script:
Any help would be much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 03:42 AM
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 03:46 AM
Hello @alabbas
Please create one schedule or choose any existing schedule.
In the script include add this code-
var schedRec = new GlideRecord('cmn_schedule'); // Query table for schedule
schedRec.get('name','8-5 weekdays excluding holidays'); // Get the schedule name
var sched = new GlideSchedule(schedRec.sys_id); // Create variable schedule
var schedTime = new GlideDateTime(selected_date); // Create variable with current date/time
if (sched.isInSchedule(schedTime))
{
gs.print('In schedule');
}
else
{
gs.print('not in schedule');
}
Mark ✔️ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 03:47 AM
check this link
Variable Date no less than 5 business days
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader