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

sachin_namjoshi
Kilo Patron
Kilo Patron

Check solution below

 

 Download Attachments as a ZIP File - ServiceNow Guru

 

Regards,

Sachin

that solution does not work in the New versions of ServiceNow.  my post is NOT a question.  I am showing you how to implement the 'download all' button.  

Iyyappan
Tera Expert

Your code is working 100%. But you have posted it as a question, either you can change it to a article or add your comment and mark that as answer.

austinbuono
ServiceNow Employee
ServiceNow Employee

I am not sure how to do that I have looked all around.  Can you help understand how to do that?