Server-side script to bulk download attachments

Mike 3ra
Tera Contributor

I need to create a script (either a REST API or a server-based script) or UI Action that will download all attachments for a given custom table. There are approx 5000 entries. So manually having a user click each one and save is out of the question. Also, the customer does not have a MID server, sending XML to MID and save on shared folder is out unfortunately.

I have searched the community and everything points back to an old (6 years) article:
https://servicenowguru.com/scripting/download-attachments-zip-file/

This didn't work for me. I get an error on the below line which states that getOutputStream is undefined.

var out = new Packages.java.util.zip.ZipOutputStream(g_response.getOutputStream());

 

I have also looked at Attachment API but don't see how it gets me what I need.

Looking for assistance or alternatives. Somewhat urgent.

Thanks

4 REPLIES 4

Community Alums
Not applicable

HI @Mike 3ra ,

Here is what you have to do : https://servicenowguru.com/scripting/download-attachments-zip-file/

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Sandeep as per my above comment I already saw that link and ran into an issue.

joshuastanley
Tera Expert

10 years old solution. Does not work any more

Astha5
Tera Expert

Hi @Mike 3ra , Did you find a solution to the above issues?

Thank you