How to close the GlideDialogWindow

rpoola
Tera Contributor

I have a requirement like if CI is not existing in the system User will add Add CI button to add CI. I have GlideDialogWindow in the UI action. I am able to save the CI but not able close the GlideDialogWindow using GlideDialogWindow.get().destroy() and stay in the same form.

 

UI Action code :

var gdw = new GlideDialogWindow('AddConfigurationItem');
gdw.setTitle('Configuration Item');
gdw.setSize(750,300);
gdw.adjustBodySize();
gdw.render();
GlideDialogWindow.get().destroy();

 

UI Page :

 

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<input type="text" id="ci" name="ci"> </input>
<button onclick="closeWindow()">Submit</button>
</g:ui_form>
</j:jelly>

 

Client Script:

function closeWindow(){
GlideDialogWindow.get().destroy(); //Close the dialog window
}

 

Processing Script:

var gr = new GlideRecord('cmdb_ci');
gr.initialize();
gr.name = request.getParameter("ci")+""; // get value of first_name input variable.
gr.insert();

 

 

 

 

Thanks

Ravi

6 REPLIES 6

Bhagya Lakshmi
Mega Guru

Hi,

Please remove GlideDialogWindow.get().destroy(); from UI action.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ravi,

You should not have the below line in your UI action. What will happen is as soon as the window is rendered it will get destroyed.

Update your UI action code as below:

UI Action code :

var gdw = new GlideDialogWindow('AddConfigurationItem');
gdw.setTitle('Configuration Item');
gdw.setSize(750,300);
gdw.adjustBodySize();
gdw.render();

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ravi,

Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ravi,

Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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