The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Download all attachments in one go from sys_attachment table

manas275hcl
Kilo Explorer

Hi,

Requirement is to download all attachments related to incidents present in instance and it should be done in few clicks not in a away that we need to click 2k-3k times.

name of attachments can be manage, i created a script which will append incident number to file name of attachment.

Any leads will be appreciated.

Regards

Manas

4 REPLIES 4

mohamadcharafed
ServiceNow Employee
ServiceNow Employee

Hi Manas,



You could use the provided API :


Attachment API


Attachment API - GET /now/attachment


Attachment API - GET /now/attachment/{sys_id}



Also another way is to create an external script to loop through all attachments linked to incidents for example, and then generate the URL from the attachment table :



https://myinstance.service-now.com/sys_attachment.do?sys_id=xxxxxxxx   (xxxxxxxx is the sys_id of the sys_attachment record)



The link above will download your file with the correct name. If you have a script to do this for you you can also have it record which incident/change this belongs to.



Cheers


Shishir Srivast
Mega Sage

rohantyagi
ServiceNow Employee
ServiceNow Employee

Can only be done as xml. no other format.


You can try the link mentioned in Shishir's response and follow this post for more discussions and ideas: How to download the attachment from multiple Incidents


Archi Davy
Tera Contributor

Hi, may be it was useful for you.

I used BR.

Script find sys ID of attachment and after use redirect URL to download it.

 

(function executeRule(current, previous /*null when async*/) {

var sysIdOfAtt;

var grA = new GlideRecord('sys_attachment');
grA.addQuery('table_sys_id', current.sys_id);  // document's sys ID which has attachment
grA.query();

if (grA.next()) {
sysIdOfAtt = grA.sys_id;
}

action.setRedirectURL('sys_attachment.do?sys_id=' + sysIdOfAtt);

})(current, previous);