Update closed note on change form with information entered on reason

BKennedy
Tera Expert

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

BKennedy_0-1696957733072.png

I modified the code as below and now its populate the outage date along with the actual end date to

BKennedy_1-1696957997813.png

What exactly am I doing wrong here, all i need is to poplate data entered on the reason field to the close note field

6 REPLIES 6

@BKennedy  If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

Shamma Negi
Kilo Sage
Kilo Sage

Client script to update work_end date. See below:

Client Side Dates in ServiceNow - ServiceNow Guru

 

 
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);
                g_form.setValue("work_end" , new GlideDateTime());
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_canceled");
}
 
function onPromptCancel() {
if (workNotesComplete)
return;
 
g_form.setValue("state", oldValue);
}
}

 

 

Thanks,

Shamma

Regards,Shamma Negi