Remove attachments using GlideSysAttachment

janpost
Kilo Contributor

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?

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

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


View solution in original post

15 REPLIES 15

Claire Ashdown3
Kilo Contributor

@Brad Tilton : Thank you for this helpful answer! I'm trying to implement something like this in a catalog page's workflow, and the deleteAttachment method works when I make the request, but fails when someone with fewer permissions makes the request. Do you know if there is a workaround such that I can still have deleteAttachment in my workflow Run Script and have it still work when users with fewer permissions submit the catalog page? Seems like this method requires the current executing user to have some sort of admin role.