Downloading All attachments using SNGuru solution to capturing all attachments on a task as a ZIP file ?

Liyakhat
Mega Expert

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??

 

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

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.

https://community.servicenow.com/community?id=community_question&sys_id=e225af43db6f67844abd5583ca96...

Kindly mark my comment as a correct answer and also helpful once worked.

 

View solution in original post

11 REPLIES 11

Hello asifnoor,

 

i see only images are downloading is it not downloading pdf,docs etc do i have to make any further changes??

Do you see pdf or docs in this line output?

gs.info("Entered into this loop"+file);

Make 1 change in the code

Replace this line

if (gr.next()){

WITH

if (gr.getRowCount() > 0){

and it will work.

 

hello asifnoor,

 

no it did not entered into the logs,only i see images png/jpg

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.