Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Prevent Delete of Upload File in "File Attachment" type field

Michael Gedzelm
Tera Contributor

Hi All.  The problem I'm having is NOT related to attaching a file to a ticket/record or using "Management Attachments" at the top of a form. This problem is completely separate and is about the "Delete" link that appears next to an uploaded file for a field that is of type "File Attachment".  There is both an Update and Delete link there.  If I click "Delete", the attachment is instantly deleted from the record (actually deleted from sys_attachment, which is associated with this record), despite the fact that it is mandatory and that I haven't clicked the Save button.  It should not allow a user to delete the contents of a mandatory field and save these changes instantly to the database (no warning, no save button).  That's really really bad behavior.  

I tried messing with ACLs and BRs on the sys_attachment table for Delete and that almost worked, but the problem is that I want to allow Updates to the attachment, and prevent Deletes.  The Update link for a File Attachment type field actually does a Delete and an Add in the sys_attachment table.  So, if I prevent Deletes from sys_attachment, it actually causes the "Update" link to fail as well (since it's trying to delete and then add).

 

In summary, how can I prevent deletes of a "file attachment" type field while allowing updates?

 

If you have had this specific issue and have fixed it, I'd love to hear from you.  Thanks.

5 REPLIES 5

I'm currently facing the exact same situation.. Did you, by any chance, found a workaround for this issue? Appreciate it if you could shed some light on this..

 

Also i agreed that it's an extremely horrid design choice to not provide a confirmation dialog for a destructive action such as this.。