Need help on date validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 12:12 AM
Hi All,
I have a requirement as follows
Add validation that can only be selected after 12 business days (from the 13th business day) from the date of application
Please let me know how to achieve the following thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 02:04 AM
HI @Anirudh_saraf ,
You can use GlideSchedule API()
Create a Schedule which contains business days
Include the schedule in the script include and you can validate from Client script and validate the date.
Example:
var startDate = new GlideDateTime('2014-10-16 02:00:00');
var endDate = new GlideDateTime('2014-10-18 04:00:00');
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue()); // gets the elapsed time in schedule
If this information helps you, kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 04:36 AM
Hi @Anirudh_saraf ,
Did the above solution did not work ?
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 07:49 PM
,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 02:38 AM
You can create a UI policy for this. Refer https://www.servicenow.com/community/itsm-forum/validation-on-date-field-to-allow-users-to-only-sele...
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.