- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you very much for your prompt reply. I really appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Another option besides using a Business Rule on sys_attachment is to control attachments using a UI Policy and an ACL. You can:
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.
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.
