How to replicate the functionality of the 'Download All' button!

austinbuono
ServiceNow Employee
ServiceNow Employee

Recently one of my customers wanted to replicate the functionality of the 'Download All' button available via the attachment paperclip. But the request was to add the related list sys_attachment to the application form and provide the user with a List Banner Button UI Action called 'download all attachments (zip)'.  To achieve this I got access to the OOB UI action and manipulated it to achieve the requested functionality.  I am sharing this with everyone because I was not able to find this solution anywhere and I do not want anyone to waste their time trying to figure this out.

Name: download all attachments (zip)

Table: sys_attachment

Active: true

Show update: true

Client: true

List banner button: true

Onclick: downloadAllAttachments()

function downloadAllAttachments() {
    //below is the OOB code that can be used for a regular UI action if you need
    //var downloadUrl = window.location.protocol + '//' + window.location.host + '/download_all_attachments.do?sysparm_sys_id=' + g_form.getUniqueValue() + "&sysparm_this_url=" + g_form.getTableName();
//below is the customized code that is needed to be added if you want to use this for a related list
var downloadUrl = top.location.protocol + "//" + top.location.host + "/download_all_attachments.do?sysparm_sys_id=" + g_form.getUniqueValue() + "&sysparm_this_url=" + g_form.getTableName();
//below is needed for the regular UI action    
//window.location = downloadUrl;
//below is needed for the List banner UI action
    top.location.href = downloadUrl;



}
7 REPLIES 7

Hello Austin,

 

Can we add the download all attachment in service operation workspace 

Hi @mahesh143 , I've just tried it and it works in SOW.

 

You have to configure a related list action with following configuration and the code suggested by @austinbuono and it works for me:

 

JoaquinCampos_0-1695203763353.png

JoaquinCampos_1-1695203872027.png

 

Hope that helps!

 

Joaquín

Hi Joaquin,

Can we add this Download All Attachment functionality to new Configurable HR Workspace 'Agent Workspace for HR Case Management'? I tried implementing the same, but it didn't work for me.