The CreatorCon Call for Content is officially open! Get started here.

Agent Workspace Issue

Michael94
Tera Contributor

Hello,

I'm trying to create a UI action that export an HR case record in both the case form in the native UI and Agent Workspace. The UI action works correctly in the native UI but does not function properly in Agent Workspace. 

 

 

20 REPLIES 20

J Siva
Kilo Patron
Kilo Patron

Hi @Michael94 
I just tried your code in my PDI by doing some minor changes. PFB the snaps/code. It's working as expected. 
Please try and let me know how it goes.
UI action script:

JSiva_0-1739789761531.png

 

 

 

function getPDF() {
    var gaViewName = new GlideAjax('global.ValidateService');
    gaViewName.addParam('sysparm_name', 'getViewName');
    gaViewName.getXML(getView);
}

function getView(response) {
    var instanceURL = "https://" + location.hostname + "/";
    var sysparm_view = response.responseXML.documentElement.getAttribute("answer");
    var sysparm_sys_id = g_form.getUniqueValue().toString();
    var url = instanceURL + 'incident.do?PDF&sys_id=' + sysparm_sys_id + '&sysparm_view=' + sysparm_view;
    top.window.open(url, '_blank');
}

 

 

 

Workspace script:

JSiva_1-1739789809490.png

 

 

 

 

function onClick(g_form) {
    var gaViewName = new GlideAjax('global.ValidateService');
    gaViewName.addParam('sysparm_name', 'getViewName');
    gaViewName.getXML(getView);
}

function getView(response) {
    var instanceURL = "https://" + location.hostname + "/";
    var sysparm_view = response.responseXML.documentElement.getAttribute("answer");
    var sysparm_sys_id = g_form.getUniqueValue().toString();
    var url = instanceURL + 'incident.do?PDF&sys_id=' + sysparm_sys_id + '&sysparm_view=' + sysparm_view;
    top.window.open(url, '_blank');
}

 

 

 

Regards,
Siva

Michael94
Tera Contributor

 

 

 I'm not sure if I get the correct response from ajax, however it's working fine in native ui action. 

Did you check my script and compare with your script? Below is working for me in the workspace.

var instanceURL = "https://" + location.hostname + "/";

 

Michael94
Tera Contributor

 

 

 

The missing part is getting the hr service value from the case form. I need it to get the correct view for the hr service and export it as pdf. 

Yep. That's intentional. Since I don't have HR module enabled, i did that testing with the incident table.
So you can just add the required lines as per your need.
And if possible could you please share your script from the script include.
Since you said, it's returning [object object].