Deleting multiple attachments the faster way

hanaphouse
Giga Guru

I have accidentally pasted multiple images into the KB article and wanted to delete all those attached images. However, it is tedious since I have to select each tick box, then click Remove. Is it possible to add a select all or remove all button?

find_real_file.png

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Charlespalma,



You can execute the below script from Background-scripts to delete the attachments.


deleteAttach();


function deleteAttach()


{


  var gr = new GlideRecord('sys_attachment');


  gr.addQuery('table_name', 'PASS TABLE NAME HERE');


  gr.orderBy('table_sys_id', 'PASS RECORD SYS_ID HERE');


  gr.query();


  while(gr.next())


  {


  gr.deleteMultiple();


  }


}



NOTE: Untested code.


Nia McCash
Mega Sage
Mega Sage

Or you can try deleting them en mass from the attachment list --   https://[instance].service-now.com/nav_to.do?uri=/sys_attachment_list.do