Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with UI Action on Workspace

shyam34
Tera Contributor

Hello All , 

I have an UI Action button which Generates Session Key from beyond this Works well on UI but not on SOW Workspace , I see in the script they used glide dialogue window but seems it is deprecated 

I tired with Glide Model but it is not working can you please check and amend the changes

 

function onClick(g_form) {
    generateERSServerSessionKey();

    function generateERSServerSessionKey() {
        var ga = new GlideAjax('x_bmgr_support_ent.BomgarRemoteSupport');
        ga.addParam('sysparm_name', 'generateSessionKeyServerSide');
        ga.addParam('sysparm_record_id', g_form.getUniqueValue());
        ga.addParam('sysparm_table_type', 'task');
        ga.getXML(handleERSServerSessionKeyCallback);
    }

    function handleERSServerSessionKeyCallback(response) {
        var answerString = response.responseXML.documentElement.getAttribute("answer");

        if (answerString === null) {
            alert('Something went wrong while attempting to generate a session key.');
            return;
        } else if (answerString.startsWith('ERROR')) {
            var error = answerString.substring(6);
            alert('An error occurred: ' + error);
            return;
        }

        var sessionKeyJson = JSON.parse(answerString);
        openLanguagePopup(sessionKeyJson);
    }

    function openLanguagePopup(sessionKeyJson) {
        var dialog = new GlideModal('bomgar_session_key');
        dialog.setTitle("Remote Support Session Key");
        dialog.setSize(620, 200);
        dialog.setPreference("session_link", sessionKeyJson.keyUrl);
        dialog.setPreference("session_key", sessionKeyJson.shortKey);
        dialog.setPreference("record_id", g_form.getUniqueValue());
        dialog.setPreference("subject", sessionKeyJson.mailSubject);
        dialog.setPreference("body", sessionKeyJson.mailBody);
        dialog.render();
    }
}
 
6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Hi @shyam34 you can try using g_modal like mentioned in below thread

https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta...

Regards
Harish

@Harish KM , I have tried but  I could not parse the JSON data which is coming from Ajax , can you help in amending that?

Hi @shyam34 can you share your script include?

I am not sure whether you can set the values directly on g_modal, may be you can set the values on some fields and use below options to display to user

HarishKM_0-1710322074189.png

 

Regards
Harish

shyam34
Tera Contributor

@Ankur Bawiskar  , any help how we can make this to work on Workspace 

 

function onClick(g_form) {

    var ui_page_id = '15090aad4f8c4200237ca5017310c703';

    g_modal.showFrame({

        url: '/ui_page.do?sys_id=' + ui_page_id,

        title: 'Session Key',

        size: 'xl',

        height: 500

    });

 

I have used above script its opening the UI page , now how to parse the data and display in the page?