Can't close a GlideModal window

Ken83
Mega Guru

Hello Community,

I've been checking every article I can find about this issue on the community but I've had no success. My goal is simple...CLOSE THE GLIDEMODAL! That's all I really want to do. To be clear, I have the X in the upper right corner of the modal dialog. That successfully closes the popup. That's not a problem. I have a button in the dialog that I want to close the dialog when it's clicked. Nothing I do from within the dialog is closing it. 

I'm getting the error that GlideDialogWindow is not defined or GlideModal is not defined or cannot read property destroy of undefined or cannot read property get of undefined. I don't know what else to try here. Suggestions? Here is my code in its current state.

find_real_file.png

find_real_file.png

8 REPLIES 8

Joe72
Tera Contributor

The syntax for this is:

new GlideModal().get(<id_of_your_modal>).destroy();


The id of your modal will usually be the name of the UI Page or whatever you called when you instantiated it. However, you can always check by finding the id of the parent div of the modal:

find_real_file.png 

Hmm..not working for me , I'm able to get modal it looks like:
Can it be because I'm rendering my UI Page in GlideModal (through gm.renderIframe)
How can I close it?

$scope.close = function(){
	var queryString = window.location.search;
	var urlParams = new URLSearchParams(queryString);
	var table = urlParams.get('table')
	var sys_id = urlParams.get('sys_id')
	console.log(table);
	console.log(sys_id);
	var a = new GlideModal().get('mymodal')
	console.log(a);
	a.destroy();
};

find_real_file.png

did you figure out how to close the iframe?

Community Alums
Not applicable

I've had this problem on and off for a few years now!!! Code that was working on a GlideModal has stopped working again.

I've just found this ServiceNow example that works fine, as long as you call the function using "g:dialog_button", also in the example.

 https://docs.servicenow.com/bundle/rome-it-service-management/page/product/incident-management/task/...

Thanks,

Jason