Planned start date must be after current date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2021 10:43 PM
In the change request I have to validate the Planned start date that it should be after the current date. I was able to create the Field level error message whenever the planned start date is earlier than the current date. But regardless of that field-level error, when a user submits the form, the wrong value is getting updated.
How can we prevent the user from submitting a form if the planned start date is selected with earliar date
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2021 10:53 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 ServiceNow Community MVP
2020 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2021 10:55 PM
Hi,
you should be using before insert/update BR to stop the form submissions
Condition: Planned Start Date Changes AND Planned Start Date is not empty
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var start = new GlideDateTime(current.start_date);
var nowTime = new GlideDateTime();
if(start.getNumericValue() < nowTime.getNumericValue()){
gs.addErrorMessage('Planned start date cannot be earlier than current time');
current.setAbortAction(true);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2021 10:56 PM
Hi,
to stop form submission you should be using onSubmit or before business rule
convert your client script to onSubmit and it should work fine
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 12:01 AM