Update closed note on change form with information entered on reason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:14 AM
When I click on cancel change, a reason popup displays, if I enter any information on that field, I like that information to automatically populate on the closed note field
I modified my ui action as below which works but causing an uncaught ReferenceError; Current is not defined
I modified the code as below and now its populate the outage date along with the actual end date to
What exactly am I doing wrong here, all i need is to poplate data entered on the reason field to the close note field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:18 AM
@BKennedy Could you please share the screenshot of the entire script.
Also, please be informed that Current object is not available in client side script, it is only available in the Server side script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:32 AM
Hi Kennedy,
This article will help you understand your issue better https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0657198
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:56 AM - edited 10-10-2023 11:00 AM
@BKennedy "Reason" pop up which is coming after clicking on "Cancel change" UI action is actually coming from client script. Below is client script which gets triggered after state of change record changes to "Cancelled" from UI action.
https://instance.service-now.com/sys_script_client.do?sys_id=aa78ab09c313101035ae3f52c1d3ae20&sysparm_view=&sysparm_domain=null&sysparm_domain_scope=null&sysparm_record_row=11&sysparm_record_rows=42&sysparm_record_list=sys_class_name%3dsys_script_client%5etableSTARTSWITHchange_request%5eORDERBYDESCsys_updated_on
So you need to update client script as below to copy reason to close notes field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || g_form.isLiveUpdating())
return;
var intOldValue = parseInt(oldValue, 10);
var intNewValue = parseInt(newValue, 10);
// We don't open the dialog if the state isn't Canceled AND if the old and new values for state are both Canceled
// This function can fire when the state field is updated via script to ensure it's populated correctly
if (intNewValue !== 4 || (intOldValue === intNewValue && intOldValue === 4))
return;
var workNotesComplete = false;
var dialog = new GlideModal('change_confirm_reason', false, 648, 250);
dialog.setTitle(new GwtMessage().getMessage('Cancel Change Request'));
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', onPromptComplete);
dialog.setPreference('onPromptCancel', onPromptCancel);
dialog.on('closeconfirm', onPromptCancel);
dialog.setPreference('buttonLabelComplete', new GwtMessage().getMessage('OK'));
dialog.setPreference('buttonLabelCancel', new GwtMessage().getMessage('Cancel'));
dialog.render();
function onPromptComplete(notes) {
workNotesComplete = true;
g_form.setValue("work_notes", notes);
g_form.setValue("close_notes", notes);
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_canceled");
}
function onPromptCancel() {
if (workNotesComplete)
return;
g_form.setValue("state", oldValue);
}
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 01:23 AM
@BKennedy If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!