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

Thank you for the reply.

I set up everything, but the attachments won't download. This is my script include. It is passing the list of sys_id's correctly, but it seems the download doesn't want to work. I also tried looping the list and that did not work either. 

var DownloadAttachments = Class.create();
DownloadAttachments.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 download: function() {
 var list = this.getParameter('sysparm_list');
 gs.setRedirect('download_all_attachments.do?sysparm_sys_id=' + list);
 return 'this worked';
 },

 type: 'DownloadAttachments'
});

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/)

Hi @shawna.gerard ,

Hope you're doing well.

Please mark the answer as helpful/correct if it has helped you solving your problem, and to close this thread, so that the other community members can refer to it as a resolved thread.

 

Thanks & Regards,

Rishabh Jha

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

Prateek kumar
Mega Sage

Please take a look at this thread.

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


Please mark my response as correct and helpful if it helped solved your question.
-Thanks