- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 03:00 PM
I have a requirement to compare change planned start and actual start. if actual start is before planned start, give user an option to select YES to continue or CANCEL to stop and not save. I create an on change client script but change does not continue when YES is selected. Can anyone help edit my script error.
function onChange(control, oldValue, newValue, isLoading, isTemplate){
if(newValue == "")
return;
var startDate = g_form.getValue("start_date");
var workDate = g_form.getValue("work_start");
var format = g_user_date_time_format;
if (startDate === "" || workDate === "")
return;
var startDateMs = getDateFromFormat(startDate, format);
var workDateMs = getDateFromFormat(workDate, format);
if (startDateMs > workDateMs) {
var answer = confirm("Change request cannot be implemented before planned start time begins");
if (!answer){
return false;
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2018 12:26 AM
In your case need to use 2 onChange client scripts so I’m not sure that is a good idea. But an onSubmit() client script can cancel form submission by returning a value of false. I attached the pictures below
Another way is to use the AJAX call. And I found a good solution on the following link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 04:05 PM
Shouldn't you use onSubmit instead of onChange?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2018 12:26 AM
In your case need to use 2 onChange client scripts so I’m not sure that is a good idea. But an onSubmit() client script can cancel form submission by returning a value of false. I attached the pictures below
Another way is to use the AJAX call. And I found a good solution on the following link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2018 03:45 AM
Thank you!
This has helpful and an working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 02:49 AM
where we have to see the confirm method in servicenow
i need to remove instance name in that popup box