- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2014 07:07 AM
Is it possible to remove attachments by using GlideSysAttachment? I'm looking for a function similar to GlideSysAttachment.copy(...), something like GlideSysAttachment.remove(...) or GlideSysAttachment.delete(...). If there is such a function where is it documented?
Solved! Go to Solution.
- 27,864 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2014 08:56 AM
If you want to remove all attachments from the record, you can use the following where recordGR is the gliderecord representing the record from which you want to remove attachments.
var attach = new GlideSysAttachment();
attach.deleteAll(recordGR);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2016 09:04 AM
Hi Brad,
But i'm unable to delete my attachments in task using this ,
var task = new GlideRecord('sc_task');
task.addQuery('request_item',current.table_sys_id);
task.query();
while(task.next()) {
gs.log("task.sysid" + task.sys_id);
var attach = new GlideSysAttachment();
attach.deleteAll(task.sys_id);
GlideSysAttachment.copy('sc_req_item', current.table_sys_id, 'sc_task', task.sys_id);
}
I'm writing this BR on sys_ attachment.
Condition builder current.table_name == 'sc_req_item'
I would like to delete all my old attachments in task and copy all my attachments from RITM everytime i add attachment to RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 07:31 AM
It appears that you're passing the "deleteAttachments" a sys_id string instead of a GlideRecord object. Try this instead...
Old code:
var attach = new GlideSysAttachment();
attach.deleteAll(task.sys_id);
New code:
var attach = new GlideSysAttachment();
attach.deleteAll(task);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 06:54 AM
Odd.. I get this:
Error running business rule 'Attachments for Approval Emails (Claims)' on sysapproval_approver:Created 08-19-2016 09:50:52:AM, exception: org.mozilla.javascript.EvaluatorException: Can't find method com.glide.ui.SysAttachment.deleteAll(string). (; line 243)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 07:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 07:27 AM
David,
Are you using this in a scoped app? If so, the available APIs are different from the global application scope (and very limited I might add).
There is a "deleteAttachement" method, but since you have to query for the attachments manually (like you did in your solution below), it doesn't make a whole lot of sense to bother with it.