Download Attachment upon clicking an UI action in Workspace.

Swathi P
Tera Guru

Hi All,

 

I have an UI action called Download Template in scoped application which downloads the attachment into system . I am trying to create a workspace View for the table and added the button in Form actions and added Workspace script . Upon clicking the Download Template button in workspace. It is redirecting to Picture 2 rather than downloading the attachment. IIt is working fine in UI 16 View Not working proper in Workspace. How to correct this . Please help.

 

Picture1:

find_real_file.png

Picture 2:

find_real_file.png

Thanks & Regards

Swathi Padighar

11 REPLIES 11

Hi,

action.setRedirectURL() won't work in workspace.

Can you share your existing UI action script

Regards
Ankur

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

This is the script which is present in UI action script .

var URL = '/sys_attachment.do?sys_id=' + attachmentSysID ;

action.setRedirectURL(url);
action.setReturnURL(current);

Hi,

As I already mentioned you need to write Workspace client script

Also the above script won't run in workspace

Also the script you shared is incomplete -> what does this attachmentSysID include?

 

find_real_file.png

Regards
Ankur

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

Attachment Sys id is attachment' sysid which is stored in Servicenow and that is the complete UI action script. I am storing the attachment's sysid in a property and getting it .

Hi,

so you missed this part i.e. you are getting the attachment sysId from prpoperty

now what you can do is this

1) in workspace client script call GlideAjax and return the sysId from property

2) update the script as this


var attachmentSysID = ''; // this value will come from GlideAjax function

var URL = '/sys_attachment.do?sys_id=' + attachmentSysID ;
var win = top.window.open(url, '_blank');
win.focus();

Regards
Ankur

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