Prevent record to be deleted if it has associated record to it

S M
Tera Contributor

Hello Guys,

I would like to prevent from any user to remove records which have associated record/s to it. I know that I have many ways to prevent deletion of the record through the ACL or the UI Action but none of those giving me the option to check if there are the associated records.

Any suggestion for the best way to do that?

Best wishes,

DH

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could write a before delete business rule that queries associated tables to see if there is are records referencing current and then do a setAbortAction(true) if so.

If there is a finite list of tables and fields you can check this is a little easier, otherwise you'll have to do something more like this.

View solution in original post

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could write a before delete business rule that queries associated tables to see if there is are records referencing current and then do a setAbortAction(true) if so.

If there is a finite list of tables and fields you can check this is a little easier, otherwise you'll have to do something more like this.

S M
Tera Contributor

Thank you!