GlideModal call back function not working - error - Uncaught ReferenceError: <<name of callback function>> is not defined

Sourabh Purani1
Kilo Explorer

I am trying to replicate the functionality of Cancel Change request on one of my custom form.

I created exactly same UI Action (Cancel Change) and UI Page (change_confirm_cancel) as that of OOTB change cancel functionality.

However, I am able to get dialog window to enter the comments but when I click on OK button on the dialog box, it does nothing (dialog doesn't get closed) and I can see error in browser debug window:

VM7492:4 Uncaught ReferenceError: moveToCancel is not defined
at HTMLButtonElement.cancelChangeRequest (eval at evalScript (js_includes_doctype.jsx?v=03-02-2020_2243&lp=Tue_Mar_03_02_34_58_PST_2020&c=5_59:84), <anonymous>:4:3)
cancelChangeRequest @ VM7492:4

 

Interestingly, same OOTB functionality, with same code works fine in Change management.

Any help appreciated.

8 REPLIES 8

Hello Ricardo Trejo,

You have to use "processing script" in UI Page.

You can find more details on docs - https://docs.servicenow.com/bundle/paris-application-development/page/script/server-scripting/reference/r_UIPages.html

HTH.

Regards,

Sourabh 

Hi Sourabh/Ricardo,

Could you please provide more details around how exactly you used the processing script in UI page to resolve this issue?  I am running into the same issue.

Regards,

Chris

 

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Community Alums
Not applicable

I've faced the same issue. 
I couldn't find anyone in community talking about this except this one (https://www.servicenow.com/community/now-platform-forum/how-to-create-a-popup-dialog-box-on-a-ui-act...).

 

So as a workaround I've cloned the OOB UI page (change_confirm_cancel) and I've defined the function moveTocancel in the client script of that UI page.
"sys_ui_page.do?sys_id=83972214c3322200b6dcdfdc64d3ae3c&sysparm_record_target=sys_ui_page&sysparm_record_row=6&sysparm_record_rows=12&sysparm_record_list=nameCONTAINScancel%5EORDERBYname"

in the client script:

MIBE_0-1664795520708.png

 

function cancelChangeRequest() {
var textArea = $("change_confirm_reason_text");
if (textArea)
moveToCancel(textArea.value.trim());
}

 

function moveToCancel(notes){

// your logic here

}

(function() {
$("change_confirm_reason_text").focus();
})();

SunilM
Tera Contributor

setCompletionCallback function is not defined in GlideModal Api whereas it is defined in GlideModalForm Api so you can use in GlideModalForm Api.

Thanks