UI Page in Workspace

shyam34
Tera Contributor

Hello @Ankur Bawiskar  ,

 

have created seperated thread and below is the need , we have UI Action called session and when it's clicked it open page and display Session link and Key , Currently we have following script in UI Action which works perfect in Native UI but fails when we use this in SOW workspace reason being GlideModal is not allowed in Workspace 

 

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();
    }
}
 
======== 
This Following Script perfectly Open/pops the page but the values are'nt parsed , can you please do how we can parse the values into the UI Page 

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

    });

} 

 

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@shyam34 

you are just calling the UI page but not sending any values to it when called from workspace

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

@Ankur Bawiskar , I dont have idea how to parse the json into this ui page logic , i was looking for help on that

@Ankur Bawiskar Any reference how we can parse JSON workspace client scripts?