- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:23 PM
Hi Team ,
There is Date Field in catalog form , attached screenshot .
If users enters current date or past date it shouldn't take and it show an error .
How to achieve this requirement .
I have tried with UI Policy ,
For this UI Policy output will be
my requirement is
If users enters current date or past date it shouldn't take and it show an error .
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:47 PM
Hi @nameisnani,
Your condition should be as below.
Condition:
Date_field is ATORBEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field");
g_form.showFieldMsg("Date_field", "Current date or past date not allowed" , "error");
}
For reference: No Code date validations through (Catalog) UI Policies
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:47 PM
Hi @nameisnani,
Your condition should be as below.
Condition:
Date_field is ATORBEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field");
g_form.showFieldMsg("Date_field", "Current date or past date not allowed" , "error");
}
For reference: No Code date validations through (Catalog) UI Policies
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 09:44 PM
function onLoad() {
var dateField = g_form.getValue('date_field');
var currentDate = new Date();
dateField.observe('change', function () {
var selectedDate = g_form.getValue('date_field');
if (selectedDate) {
if (new Date(selectedDate) <= currentDate) {
alert("Please select a future date.");
g_form.setValue('date_field', '');
}
}
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 09:50 PM
Hi there,
Have a look at this article which I wrote 4 years ago. Still valid!
- 2019-08-12 - Article - No Code date validations thru (Catalog) UI Policies
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field