Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Restrict public holidays and weekends from being selected in a form

alabbas
Tera Contributor

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:

alabbas_0-1747820281690.png

The commented out part is something else I was trying.

Client script:

alabbas_1-1747820676148.png

Any help would be much appreciated!

3 REPLIES 3

bhaveshbawa
Tera Contributor

 

https://www.servicenow.com/community/developer-articles/select-only-business-days-excluding-holidays...

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Harsh_Deep
Giga Sage
Giga Sage

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. 

Ankur Bawiskar
Tera Patron
Tera Patron

@alabbas 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader