How to Control Attachments for RITMs After a Specific Status.

Ryota
Tera Guru

Is it possible to implement this using a Business Rule: prevent attachments from being added or deleted for RITM records of a specific catalog item when the state is Work in Progress or later?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Ryota 

yes you can use before insert before delete business rule on sys_attachment

Before Delete and Before Insert

Condition: current.table_name == 'sc_req_item'

Script:

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

    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.table_sys_id)) {
        if (ritm.cat_item == 'YOUR_CATALOG_ITEM_SYS_ID' && ritm.state >= 2) { // 2 = Work in Progress
            gs.addErrorMessage('Attachments cannot be added for this RITM in Work in Progress or later state.');
            current.setAbortAction(true);
        }
    }
	
})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Ryota 

yes you can use before insert before delete business rule on sys_attachment

Before Delete and Before Insert

Condition: current.table_name == 'sc_req_item'

Script:

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

    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.table_sys_id)) {
        if (ritm.cat_item == 'YOUR_CATALOG_ITEM_SYS_ID' && ritm.state >= 2) { // 2 = Work in Progress
            gs.addErrorMessage('Attachments cannot be added for this RITM in Work in Progress or later state.');
            current.setAbortAction(true);
        }
    }
	
})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you very much for your prompt reply. I really appreciate your help.

pr8172510
Tera Contributor

Another approach (without using back-end Business Rules) is to block attachments using a UI Policy + ACL combination.

• UI Policy to hide/disable “Add Attachment” when the RITM is in Work in Progress or later
• Delete ACL on sys_attachment to prevent attachment removal when those conditions match

This avoids BR error messages and keeps the restriction more maintainable, while still blocking API/script-based actions through ACL.

pr8172510
Tera Contributor

Another option besides using a Business Rule on sys_attachment is to control attachments using a UI Policy and an ACL. You can:

  1. Create a UI Policy on sc_req_item that checks if the catalog item matches and the state is Work in Progress or later, and disable the Add Attachment option in the UI. This prevents users from attaching files once the RITM reaches that stage.

  2. Create a Delete ACL on sys_attachment to prevent removal of attachments when the linked RITM meets the same condition. This gives cleaner behavior without showing a back-end error message like a Business Rule and is easier to maintain.

This approach handles both preventing new attachments and stopping deletion while keeping the user experience smoother.