Open popup with a client script on Agent Workspace

Boaz Benicio
Tera Contributor

Hi guys, I need your help! I'm trying to redirect users with an Workspace UI Action, it's working in Native UI but not in Agent Workspace.
Could someone help me with it, pleeease? Here is my code:
I copied it from an native UIAction and just fit it for my business


    if (g_form.getValue('u_docintel_task') != '') {
        var taskId = g_form.getValue('u_docintel_task');
    }
    var taskName = g_form.getDisplayValue('u_docintel_task');
    alert(taskId + taskName);
    var url = new GlideURL('$docintel.do');
    url.addParam('task_id', taskId);
    url.addParam('task_name', taskName);

    var targetWindow = g_navigation.openPopup(url.getURL());

    var isViewer = g_user.hasRoleExactly('sn_docintel.viewer');
    targetWindow.sessionStorage.setItem('isViewer', isViewer);

#clientscript #agentworkspace #workspace #coding #scripting #popup

1 ACCEPTED SOLUTION

Markus Kraus
Kilo Sage

The "Continue problem" UI Action of the OOTB Service Operations Workspace (/nav_to.do?uri=sys_ui_action.do?sys_id=97d3a3b1eb900110e69783402a52286c):

MarkusKraus_0-1685389659148.png

open(...) is basically equivalent to g_navigation.openPopup

View solution in original post

5 REPLIES 5

Andrei Guimarae
Tera Contributor

Hi @Boaz Benicio , Did you try use g_aw.openRecord ? If I understood the link you are trying to open is a record. You can do this using the method mentioned. Take a look here: https://developer.servicenow.com/dev.do#!/reference/api/rome/client/GlideAgentWorkspaceAPI It's not that complex. Hope it helps you.

 

Example, Add this (replace table name and id of the record you want to open) script to open record in a subtab:

g_aw.openRecord('table_name', '62826bf03710200044e0bfc8bcbe5df1');

Markus Kraus
Kilo Sage

The "Continue problem" UI Action of the OOTB Service Operations Workspace (/nav_to.do?uri=sys_ui_action.do?sys_id=97d3a3b1eb900110e69783402a52286c):

MarkusKraus_0-1685389659148.png

open(...) is basically equivalent to g_navigation.openPopup

Yes. The example I gave first opens inside workspace portal in a subtab. Your example OOTB open a new URL. If it covers your needs. Great! Let me know if it helps you.

You're welcome 🙂

Would you mind selecting the answer as "solution" to mark the thread as "answered"?