How to download all attachments from a table

shawna_gerard
Kilo Contributor

I have a requirement to download all attachments on a table from a button. I have tried using a UI Action and Processor, via this link 

https://www.servicenowguru.com/scripting/download-attachments-zip-file/#comment-34336

But It cannot find the Processor. I believe I read that it is deprecated now as I am in New York. 

Does anyone have a current solution to this?

1 ACCEPTED SOLUTION

Hi @shawna.gerard ,

 

I got it working as a list UI action on incident table. You'll get one zip for each sys_id passed.

Below is the UI action script:

function downloadAll() {
  selSysIds = g_list.getChecked();
  sysIdList = selSysIds.split(',');
  for (var i=0;i<=sysIdList.length;i++)
  {
    window.open('/download_all_attachments.do?sysparm_sys_id='+sysIdList[i],"_blank");
  }

}




Here's the UI Action screenshot for the setting that I had used:

find_real_file.png

 

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)

View solution in original post

13 REPLIES 13

Ah. I see the OOB Processor. I am able to download from a single record. Is there a way to download from a list of records?

Hi @shawna.gerard ,

I thought you said "I have a requirement to download all attachments on a closed case, on a custom table, from a button.", so assumed that you want to download all the attachments from a record.

 

You can try it, probably by calling it in a loop, and passing individual sys_ids to the processor.

 

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)

I apologize. I will change the description. I need to download from multiple records.

I tried the loop but it will only ever download the last attachment in the list of records.

You can wrap the processor call in a script include, and then call that script include from the UI action.

Make the UI action as a "List Choice", so that it'd appear on the list when you select multiple records, and click on "Action on Selected Rows".

You can get the selected record ids in the UI action by using the below snippet:

selSysIds = g_list.getChecked();
sysIdList = selSysIds.split(',');


//call the script include and pass the sysIdList

 

BTW, I checked that snguru link that you've posted above, and that's also for a single record.

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)