- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:10 PM
Hi!
I'm trying to write a simple Client Script that would compare Planned Start Date and Planned End Date for Change Requests to ensure end dates are kept within 24 hours of the start date.
I've tried the below script with and without the parseInt() lines and neither seems to be working correctly. I presume I need to convert the original start_date and end_date values to seconds in order to add 86400 (24 hours in seconds), but I haven't found anything that works with Client Scripts yet.
Is there a simple way to do this, or can this only be done via Inline Scripts?
Thanks!
function onSubmit() {
var start_date = g_form.getValue('start_date');
var start_date_int = parseInt(start_date);
var end_date = g_form.getValue('end_date');
var end_date_int = parseInt(end_date);
var add_time = 60*60*24;
var new_end_date = start_date_int + add_time;
if (end_date_int > new_end_date) {
alert("End Date must be within 24 hours of Start Date ");
return false;
}
}
Solved! Go to Solution.
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:33 PM
Hello,
You can easily do with this UI policy.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 12:04 AM
@Jeff Ward Tried and Tested solution. Please use below code
ServiceNow Community Rising Star, Class of 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:33 PM
Hello,
You can easily do with this UI policy.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 12:39 PM
Can the UI Policy condition factor in 24 BUSINESS hours instead?
Thanks,
Ron Hoyt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 12:04 AM
@Jeff Ward Tried and Tested solution. Please use below code
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:02 AM
Perfect! Thank you both for the replies. This is now working as expected.
Take care!