Ui page from OnSubmit client script not working

prasannakumard
Tera Guru

Hi Team,

 

We have created a UI page and that display when submitting the Catalog item. We have write script for the same, but, the after submitting the catalog item, UI page appears and If I click on OK the UI page button, UI page is disappear and catalog item stays on the same form. Please let me know where exactly modify the script.

 

UI page client scrpt:

function cancel(){
GlideDialogWindow.get().destroy(); //Close the dialog window
return false;
}
function submit(){
GlideDialogWindow.get().destroy();
return true;
}

 

Catalog item onSubmit script:

 

function onSubmit() {

//show modal dialog

var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;

var dialog = new dialogClass("Acknowledgement");

dialog.setTitle("Acknowledgement");

dialog.setWidth(600);

dialog.render();

return false;

}

Thanks & Regards,

Prasanna Kumar

16 REPLIES 16

Community Alums
Not applicable

Hi @prasannakumard 

 

I see that in the UI Page client script, submit function has the below line of code

 

GlideDialogWindow.get().destroy();

 

because of this it is disappearing.

@Community Alums Yes GlideDialogWindow.get().destroy(); is for disappearing the UI page. That means, once you click on ok then the UI page should disappear and the Catalog item should submit. Here my issue is UI page is disappearing, but catalog item stay on previous page only, it is not submitting. 

Thanks & Regards,

Prasanna Kumar

Tim Woodruff
Mega Guru

The problem is that your client script is returning false, which prevents submission. You'll need a two-step script to resolve this. 

 

I've written an article with detailed instructions on exactly how to solve this issue, as it's very common for any asynchronous logic that needs to happen in onSubmit client scripts in ServiceNow. You can find that article at https://onsubmit.snc.guru - this is the solution to your issue. 🙂

@Tim Woodruff  Thank you for you response. But, how would I include UI page in this script? can you help on to include UI page in your script.

 

Catalog item onSubmit script:

 

function onSubmit() {

//show modal dialog

var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;

var dialog = new dialogClass("Acknowledgement");

dialog.setTitle("Acknowledgement");

dialog.setWidth(600);

dialog.render();

return false;

}

Thanks & Regards,

Prasanna Kumar