Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to restrict users from deleting attachments on specific tables - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to restrict users from deleting attachments on specific tables
KB0825743

How to restrict users from deleting attachments on specific tables


5946 Views Last updated : May 25, 2023 public Copy Permalink
KB Summary by Now Assist

Issue

This article helps with restrict users from deleting attachments in a specific table (eg. Requested Item)

Resolution

The 'Manage Attachments' popup on a record is a UI page of attachment wherein removing the 'Remove' button will remove the button globally, and not specific to a table.

Restricting users from delete attachments on a table can be achieved by adding a before-delete business rule

Note: In this method, we are allowing users to click on the 'remove' button and the attachment disappears with the UI behavior; but when you reload the record, the attachment shows up (because the attachment was never deleted on the server-side because the business rule operation has aborted the action)

In below examples, the before-delete business rule restricts users other than Admin to abort deleting the attachment on the 'sc_req_item' table

Name: Restrict Delete attachment on RITM
Table: sys_attachment
Advanced: check
When: Before
Delete: check


Filter Condition: Table Name is sc_req_item

Script Conditon:

(function executeRule(current, previous /*null when async*/) {

// Add your code here

if(!gs.hasRole('admin')){

current.setAbortAction(true);

}
})(current, previous);

 

Related Links

This business rule works primarily to prevent deletion of the record in the sys_attachment table.  If when reloading the task, the attachment reappears with an attachment of 0 bytes; this is because the base64 data for the file was deleted from the sys_attachment_doc table which resulted in a broken attachment link with an empty file.

Solve this by adding a matching "on before delete" business rule to both of these tables:
sys_attachment
sys_attachment_doc


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.