- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2021 09:45 AM
User needs to be restricted when user selects the past time in the date fields in the change form. Need to create BR / client script against The Planned Start and End times along with the Outage Start and End times. The business rule/ Client script should prevent all ITIL users from setting a date and time in the past based on their current system time.
I have created Below script include and client script. It is working on preventing user if he selects previous date. But I want to restrict user to select past time also. Please give me solution.
Script Include:
Client Script:
I have created OnChange Client Script on Planned Start date field as below.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 08:26 AM
Hello
Please use my below working Scripts, I have achieved this in my PDI. You only need to replace your variables.
onChange Catalog Client Script:-
1) Client Script for Future Date Validation:-
2) Past Date Validation:-
3) Common Client Callable Script Include:-
4) Script Include Code;-
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2021 09:55 AM
Hi,
Please check below Link.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2021 09:48 PM
Hi
the following script iterates over all fields of the current record and filters out all of the type 'glide_date' and 'glide_date_time'. Then it checks whether its value is less than the current timestamp (compared on the basis of milliseconds).
var numNowMillis = new GlideDateTime().getNumericValue();
for (var x in current) {
if (x.substr(0,3) != 'sys') {
var internalType = current.getElement(x).getED().getInternalType();
if (internalType.substr(0, 10) == 'glide_date') {
var numMillis = current[x].getGlideObject().getNumericValue();
if (numMillis > 0 && numMillis < numNowMillis) {
//insert error message here
}
}
}
}
Kind regards
Maik
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 02:57 AM
Thanks for your response. But where can I use this code like BR or Script include. I have used your script in BR but its not executed as expected.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2021 10:09 PM
Hi there,
Have you considered using a (Catalog) UI Policy to achieve date validations? There's almost no-code needed to achieve date validations this way. Have a look at an article I wrote on this:
No Code date validations thru (Catalog) UI Policies
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2021 ServiceNow Community MVP
2020-2201 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field