
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 12:02 AM
Hello All,
I am trying to download all the attachments from attachment table for incidents/request items
i have seen a solution provided by servicenow guru
https://www.servicenowguru.com/scripting/download-attachments-zip-file/
this works fine for single incident/request item and it downloads perfectly
my requirement is to download all the attachments from the attachments table,here we are passing sys_id and table name from ui action to script processor ,can we pass multiple sys_ids and loop through it to download all attachments of all incidents??
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 12:52 AM
Hi Liyakhat,
I have provided a similar solution earlier here in the community.
Kindly refer to this link where I have tweaked the code to download all attachments as a zip file. Follow the steps given in the Accepted answer in this link and it will work for you.
Kindly mark my comment as a correct answer and also helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 01:27 AM
Hello asifnoor,
i see only images are downloading is it not downloading pdf,docs etc do i have to make any further changes??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 01:39 AM
Do you see pdf or docs in this line output?
gs.info("Entered into this loop"+file);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 01:50 AM
Make 1 change in the code
Replace this line
if (gr.next()){
WITH
if (gr.getRowCount() > 0){
and it will work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 01:51 AM
hello asifnoor,
no it did not entered into the logs,only i see images png/jpg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 01:58 AM
The line is present in the while loop, so you should get that log.
Also make the above change in code which i gave in my last post and then check.