Download multiple attachments from multiple records in a zip file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020 10:33 PM
Hi All,
I have a requirement to download an attachment from multiple records in zip file. I have seen the ServiceNow guru solution but that solution is no more working in New York. As the processor is depreciated hence we cant use that solution anymore.
Kindly advise if anyone has done the same.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020 10:47 PM
Hi,
Hope below code will help you:
You can use the ZipArchive
class to create a ZIP file and stream it to the client. Something like:
$files = array('readme.txt', 'test.html', 'image.gif');
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
and to stream it:
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);https://www.servicenowguru.com/scripting/download-attachments-zip-file/#comment-34336
NOTE: Mark correct or helpful if it helps you.
Warm Regards,
Tanushree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020 11:12 PM
Hi Tanushree-
I have seen this post earlier but I dint get how to implement the same? As mentioned in my post also, i have seen servicenow guru solution but that solution is not working in New York version and I suspect this will also not work.
Did you try the same in New York?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020 10:54 PM
Hi Abhishek,
Do you want all attachments on a record to be downloaded?
if yes then check below link and it may help you:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
02-02-2020 11:10 PM
Hi Ankur- Would this download all attachments as zip file?