How to close GlideDialogWindow

niuweili
Mega Contributor

Cannot close the dialog created by the UI action.
ui action onClick:

function onClick() {
    var sysId = g_form.getUniqueValue();

    console.log("=== Notification Dialog Initialization ===");
    console.log("Incident sys_id: " + sysId);

    if (g_form.isNewRecord()) {
        alert("Please save the incident record before sending notifications.");
        return false;
    }

    if (!sysId || sysId == '-1' || sysId.length != 32) {
        alert("Unable to retrieve valid incident ID. Please refresh the page and try again.");
        return false;
    }

    var assignmentGroup = g_form.getValue('assignment_group');
    var assignedTo = g_form.getValue('assigned_to');

    console.log("assignment_group: " + assignmentGroup);
    console.log("assigned_to: " + assignedTo);

    var timestamp = new Date().getTime();
    var dialog = new GlideDialogWindow('Notification Settings', 'incident_webhook_form');

    dialog.addParm('incident_sys_id', sysId);
    dialog.addParm('assignment_group', assignmentGroup || '');
    dialog.addParm('assigned_to', assignedTo || '');
    dialog.addParm('_ts', timestamp);

    dialog.setSize(750, 'auto');
    dialog.adjustBodySize();

    dialog.render();

}

 ui pages:

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:ui_form>
        ...
 		<g:dialog_buttons_ok_cancel ok="return submitForm()" cancel="return closeDialog()" />
    </g:ui_form>
</j:jelly>
function closeDialog() {
	GlideDialogWindow.get().destroy();   // No
       // window.opener.location.reload();    No
	return true;
}

Uncaught TypeError: GlideDialogWindow.get is not a function 

2 REPLIES 2

RaghavSh
Mega Patron

@niuweili IS this behaviour on workspace?


Raghav
MVP 2023
LinkedIn

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @niuweili - The GlideDialogWindow API has been deprecated, you should use the GlideModal API instead. Also, I've not seen the addParm() method used with the GlideDialogWindow API; only GlideDialogForm/GlideModalForm/GlidePaneForm. I'm not sure it's supported.

 

Please reference the documentation here: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...