setabort action not working for delete

ABC6
Tera Contributor

i have to restrict non admin user to stop deleting attachment from std_change_record_producer for which i have written below code against std_change_record_producer its a before delete, please let me know where i am doing wrong , even log is not generating for the same

ABC6_0-1742387823040.png

 

1 ACCEPTED SOLUTION

@ABC6 

The lead should already know the reason.

Reason is the delete actually works on sys_attachment as attachment is getting deleted and not the actual record on which the attachment is present.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

9 REPLIES 9

@ABC6 

The lead should already know the reason.

Reason is the delete actually works on sys_attachment as attachment is getting deleted and not the actual record on which the attachment is present.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

SanjivMeher
Kilo Patron
Kilo Patron

Your business rule should be on the sys_attachment table instead of std_change_record_producer.

Deleting attachment will trigger BR in the attachment table. Make sure to add appropriate condition in the BR on the attachment table.


Please mark this response as correct or helpful if it assisted you with your question.

ABC6
Tera Contributor

i have to do with the same, please expedite my query

You can't on std_change_record_producer, since the BR wont trigger. 

Your lead need to understand what is feasible. Another option would be to use access control on attachment table, to not allow delete if table is std_change_record_producer. It would be more complex, since attachment is a system table and you will have to be careful while adding ACLs and need proper testing.


Please mark this response as correct or helpful if it assisted you with your question.

ABC6
Tera Contributor

Any specific reason for this , please let me know