- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 10:57 PM
i have two fields named as start date and end date, both are of date and time fields.I want to make validation on start date it should not be previous date and end date should be on start date. and start date time must be less than end date time .
i have performed the functionality through ui policies but it still taking end date to tomorrow date!
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 11:23 PM
To make your search easier, I've copied the images from the article.
Again, no need for client script, glide ajax, etc.. There's just no valid reason for doing this.
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 11:01 PM
Hi there,
Because you mention date/time field, this should be achievable with (Catalog) UI Policy. Have a look at an article I wrote on this:
No Code date validations thru (Catalog) UI Policies
The article also contains a detailed example of comparing two fields with each other.
You do mention you tried already something, which is not working. Can you share anything?
Absolute NO reason to script this with client script, glideajax, etc..
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 11:30 PM
hi Harish
try this:
You can use the Onchange Client and Script Include as below
Onchnage Client Script:
var ga = new GlideAjax('BlackoutDateValid');
ga.addParam('sysparm_name', 'EndDate');
ga.addParam('sysparm_startDate', g_form.getValue('upb_start_date'));
ga.addParam('sysparm_endDate', g_form.getValue('upb_end_date'));
ga.getXMLAnswer(validateEndDate);
}
}
function validateEndDate(answer){
if(answer == 1 || answer == '1'){
alert('Blackout End Date should be greater or equal to Blackout Start Date');
g_form.clearValue('upb_end_date');
}
}
Script Include:
EndDate : function(){
var _startDate = new GlideDateTime(this.getParameter('sysparm_startDate'));
var _endDate = new GlideDateTime(this.getParameter('sysparm_endDate'));
return _startDate.compareTo(_endDate);
}
___________________________________________________________
if for more detail refer the following thread (blog) 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
‎03-25-2020 11:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2020 02:47 AM
client side code is not working.