Date Validation Catalog UI policy not working on Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:15 AM
Hi Guys,
I have a written a catalog ui policy for a variable set to restrict date variable to allow only current and future dates. The ui policy is working fine on platform view. But not working on service portal. Below are the screenshots of my ui policy.
I have selected UI type to "All" but still no luck. Any suggestions?
I have also tried catalog client script as below, But it is triggering even if the current date is selected.so looks like script is not working for current date, it is only working for future dates.
script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type //get the entered date string
var enteredDate= g_form.getValue('start_date');
//get the current date/time
var rightNow = new Date().valueOf();
var dateToCheck = new Date(enteredDate).valueOf();
if (dateToCheck < rightNow)
{
//Display Error Message
g_form.addErrorMessage(getMessage('Select appropriate date'));
g_form.setValue('start_date','');
}
}
Thanks,
Rocky.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:54 AM
Hi Rocky
All the client scripts are doing a GlideAjax call to a script include 'DateTimeFunc'. Make sure you set the UI Type to All in client script to make it work in Service Portal.
While using them in an onSubmit script, use getXMLWait() instead of a callback function. Because an onSubmit will not wait for a callback since callbacks are asynchronous.
If you don't want to write another onSubmit script, you can set the field value blank when validation fails by using g_form.setValue('start_date',''), so that user must enter a another date.
refer the following block it help you.
https://community.servicenow.com/community?id=community_blog&sys_id=467c62e1dbd0dbc01dcaf3231f9619ad
If it help mark helpful or correct
Thanks and regards
Anil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:55 AM
https://hi.service-now.com/kb_view.do?sysparm_article=KB0748829
It seems to be known error and has been fixed by some patches. Please make sure to validate the current version of your instance. If you think, everything is okay with your instance, please create HI ticket accordingly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 10:02 AM
Hi Rocky,
If this concerns a company instance, log a case at HI. For date fields this should work fine, so then there might be something with your instance.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field