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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2020 02:08 PM
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;
}
- 2,357 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2020 02:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2020 02:29 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 02:09 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 02:18 PM
I am not sure how to do that I have looked all around. Can you help understand how to do that?