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

You already know how to launch a UI page in a modal; and the article shows you exactly how to do what you need to do. You just have to re-submit the form after setting the client data after the modal is done. 

Ankur Bawiskar
Tera Patron
Tera Patron

@prasannakumard 

Is your requirement just to show some standard message in UI page box during submission?

OR

you want to show the message to user and only when they click OK the catalog item should get submitted?

As per your script it has return false so it's stopping form submission

update script as this

function onSubmit() {

//show modal dialog
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass("Acknowledgement");
dialog.setTitle("Acknowledgement");
dialog.setWidth(600);
dialog.render();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar ,

1) When submitting the Catalog item "UI page" should show,

2) If you click OK/Cancel, after catalog item should submit. 

Why I'm using return false, after submitting the catalog item, UI page appear and in few seconds catalog item getting submitted. (there is no time to click Ok/Cancel in UI page)

Hope you understand the situation. Please help on the same.

Thanks & Regards, 

Prasanna Kumar

@prasannakumard 

then do this

1) show UI page on the submit and use return false

2) then on click of OK submit the form via client script of UI page

use this

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;
}

UI Page

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

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you @Ankur Bawiskar ,

Almost reached the solution. But, I'm using the client script in UI page as you mentioned above.

I got error on Catalog form as below:

prasannakumard_0-1677581810907.png

"The g_form.submit function has no meaning on a catlog item. Perhaps you mean g_form.addToCart() or g_form.orderNow() instead"

So, I changed the UI page Client script as mentioned below:

function cancel(){
	GlideDialogWindow.get().destroy(); //Close the dialog window
	return false;
}
function submit(){
	
	GlideDialogWindow.get().destroy();
	g_form.orderNow(); // Changed as per mentioned error.
	return true;
}

The issue is same like, after submitting the OK/Cancel, it stays on Catalog form itself. It is not working on Portal side as well. Please suggest any other solutions works on Portal and Native side.

 

Thanks & Regards,

Prasanna Kumar