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
Tera Sage

Hi @Michael94 
Good day.
Instead of using openPopup(url), use top.window.open(url,"_blank").
It's working fine for me.
Thanks,
Siva

Michael94
Tera Contributor

Thanks, I tried it but still not working. I found this article by @Musab Rasheed, however I'm not sure what I'm missing:

https://www.servicenow.com/community/itsm-articles/export-to-pdf-in-agent-workspace-form-view-with-e...

Ankur Bawiskar
Tera Patron
Tera Patron

@Michael94 

use this

function onClick(g_form) {
 exportPDF();
 function exportPDF() { 
     var hrService = g_form.getValue('hr_service');
     var gaViewName = new GlideAjax('sn_hr.validateService');
      gaViewName.addParam('sysparm_name', 'getViewName');
      gaViewName.addParam('sysparm_service',hrService);
      gaViewName.getXML(getView); 
} 
function getView(response) {
      var instanceURL = "https://"+location.hostname+"/";
      var sysparm_view = response.responseXML.documentElement.getAttribute("answer");
      var sysparm_table = g_form.getTableName(); 
	  var sysparm_sys_id = g_form.getUniqueValue().toString(); 
	  var url = instanceURL +'sn_hr_case.do?PDF&sys_id=' +  sysparm_sys_id+'&sysparm_view='+sysparm_view; 
 
	  open(url);
}}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar 

Thanks, I tried but still not working. 

I'm using almost the same script for the UI action Script and for the Workspace Client Script. What do you think about the URL? Don't you think Agent Workspace may require a different URL format for opening the PDF?