- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 09:56 PM
Hi Team,
Can anyone help me,How to remove multiple attachment from 2 tickets.
Regards,
Saridha.L
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:15 PM
Use this script to remove all attachments:
var attachment = new GlideSysAttachment();
var agr = attachment.getAllAttachments("<table_name>" <record_Sys_id>");
//example: var agr =attachment.getAllAttachments("incident","7123398d4f317a048d853d828110c731");
while(agr.next()) {
attachment.deleteAttachment(agr.getValue("sys_id"));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 10:48 PM
Hi, Thank you for your response.
There are10000+ attachments in 2 tickets,but there is no option to select all in manage attachments.
Please help.
Regards,
Saridha.L
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:03 PM
In your case it might be better to run script that will delete all attachments for needed record.
For Example,
if you have Incident record with multiple attachments and you know sys_id(lets say sys_id == 'incidentID') of the incident,
script will look like this:
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id','incidentID'); // selecting only records that belong to our incident
gr.addQuery('table_name','incident');
gr.deleteMultiple();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:15 PM
Use this script to remove all attachments:
var attachment = new GlideSysAttachment();
var agr = attachment.getAllAttachments("<table_name>" <record_Sys_id>");
//example: var agr =attachment.getAllAttachments("incident","7123398d4f317a048d853d828110c731");
while(agr.next()) {
attachment.deleteAttachment(agr.getValue("sys_id"));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2020 03:17 AM
Easier way of deleting attachments is via method deleteAll.
var attach = new GlideSysAttachment();
attach.deleteAll(recordGR);
Please refer to the conversation Remove attachments using GlideSysAttachment