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

rpoola
Tera Contributor

Hi Ankur,

It didn't work to me. I have provided alternative solution for that requirement.

 

Thanks

Ravikiran

TomaszO
Giga Contributor

Hi Guys, I have a similar problem and was not able to solve it.

I call UI Page as dialog from UI Action.

function OpenSqlDialogDialog()
{
var dialog = new GlideDialogWindow('U4SQLQueryExecute');
dialog.setTitle("Run custom SQL query");
dialog.setSize(400,400);
dialog.setPreference('sys_id',g_form.getUniqueValue());
dialog.render();
}

Dialog is shown properly but when I want to close the dialog after pressing OK it closes dialog and redirect to UI Page ( which was previously shown in dialog ).

 

OK function script:

function continueOk()
{
var dlg = GlideDialogWindow.get();
var queryId = gel('query_ref').value;
var param1Id = gel('parameter1Id').value;
var param2Id = gel('parameter2Id').value;
var parentId = dlg.getPreference('sys_id');
GlideDialogWindow.get().destroy();
return true;

}

 

How to properly close dialog if not by using function GlideDialogWindow.get().destroy() ?