
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 10:39 AM
Hello All:
I have a UI action in both Classic UI and Workspace that allows an agent to download a document from the sys_attachment table. The doc is not directly attached to the case but to another record that is related to the case.
For the classic UI I am using the g_navigation.openRecord method and all is working fine. It appears that this method is not supported in the Workspace client script as I get an error when I turn on Inspect in Chrome. How can I implement what I need in workspace. Below is the code for both the classic and workspace scripts.
//classic ui script
var my_ga = new GlideAjax('x_cpts_onboarding.CPTSApplicationDocs');
my_ga.addParam('sysparm_name', 'getRebateAttachment');
my_ga.addParam('sysparm_rebatesValue', g_form.getValue('rebates'));
my_ga.getXML(ValidateData);
}
function ValidateData(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer != '') {
g_navigation.openRecord('sys_attachment', answer);
}
Workspace Client Script
function onClick(g_form) {
var my_ga = new GlideAjax('x_cpts_onboarding.CPTSApplicationDocs');
my_ga.addParam('sysparm_name', 'getRebateAttachment');
my_ga.addParam('sysparm_rebatesValue', g_form.getValue('rebates'));
my_ga.getXMLAnswer(function(response) {
if (response) {
g_navigation.openRecord('sys_attachment', response);
}
});
}
Thanks in advance for your time!
Mahesh
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 07:23 AM
Not sure if there is a better solution, but the below code worked for me in workspace.
top.window.open("/sys_attachment.do?sys_id=" + response, '_blank');
I wasn't able to download an attachment via UI action with the OOB workspace APIs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 10:45 AM
For workspace you can try using g_aw.openRecord();
g_aw.openRecord('sys_attachment', response);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 11:11 AM
I tried that api as well Elijah. It opens another tab and shows that record but is not downloading it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 07:23 AM
Not sure if there is a better solution, but the below code worked for me in workspace.
top.window.open("/sys_attachment.do?sys_id=" + response, '_blank');
I wasn't able to download an attachment via UI action with the OOB workspace APIs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 10:08 AM
Thanks a bunch @Elijah Aromola !!