- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 11:31 PM
I want to download some attachement of multiple records at once, Is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 09:52 PM
try this
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
alert(123);
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 11:11 PM
Hi,
please allow pop-ups in your browser and it will open each url in new tab and auto-download those files.
It has worked for me.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 12:17 AM
It worked, Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 09:52 PM
try this
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
alert(123);
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 02:09 AM
My script is on the Incident table, and I would like to know how we download attachments as filename + user(who attach the attachment)
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
//alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
// alert(123);
var filename = gr.file_name;
alert(filename);
var created = gr.sys_created_by;
alert(created);
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 12:11 PM
Hi, this is working to download all attachments on a table, but it seems to only download 1 attachment on records where there are multiple attachments uploaded. Any idea on how to fix this? I've tried "/download_all_attachments.do?sysparm_sys_id=" which is not working in bulk