Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to destroy GlideModel in workspace using UI action?

Sneha_Krishna1
Tera Contributor

Hi All,
My requirement is to destroy GlideModel in workspace after validation successful.

I created one UI page, below is the code of the UI page 

function validateCode() {
    var inputFieldValue = gel('inputField').value;
    var sendData = new GlideAjax("VerifyUser");
    sendData.addParam('sysparm_name', 'sendData');
    sendData.getXMLAnswer(getData);
    function getData(answer) {
        var detail = answer.split(',');
        var code = detail[0];
        var view = detail[1];
        var record = detail[2];
        var assigned = detail[3];
        if (inputFieldValue == code) {
            call('pass');
            alert('Validation successful!');
            if (view == 'native')
                GlideModal.get().destroy();

            if (view == 'workspace')
                GlideDialogWindow.get().destroy();

        } else {
            call('fail');
            alert('Validation failed. Code does not match');
        }
        function call(output) {
            var send = new GlideAjax("VerificationLog");
            send.addParam('sysparm_name', 'createRecord');
            send.addParam('sysparm_result', output);
            send.addParam('sysparm_record', record);
            send.addParam('sysparm_verify', assigned);
            send.getXMLAnswer(getResponse);
            function getResponse(response) {
                //console.log("Completed");
            }
        }
    }
}

and UI action workspace client script is 
 var ui_page_id = 'f5f3b239db95ce9005edd9fcd39619b6'; // Specify the ID of the UI Page to be displayed in the modal
        g_modal.showFrame({
            url: '/ui_page.do?sys_id=' + ui_page_id,// Construct the URL of the UI Page using its sys_id
            title: 'Verification needed',// Set the title of the modal dialog
            size: 'lg', // Specify the size of the modal dialog (lg for large)
            height: 350 // Set the height of the modal dialog
        });

Can anyone help me how can I destroy this model in workspace?

 

 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Sneha_Krishna1 

can user not click the cross icon?

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

@Ankur Bawiskar 
We can but the requirement is to destroy the model if validation is successful without clicking the cross icon or close button. 

@Sneha_Krishna1 

check this link

How to use UI Actions in Workspaces 

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

@Ankur Bawiskar 

Can you help me with the code? I'm unable to do it.

Thanks