Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Br to prevent deletion

nafiz435
Tera Contributor

Can anyone share a business rule script example that prevents record deletion under certain conditions

1 ACCEPTED SOLUTION

Its_Azar
Tera Guru
Tera Guru

Hi there @Yashsvi 

 

you can use an br like below

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

    /
    if (current.u_status === 'Closed' && current.u_impact === 'High') {
        gs.addErrorMessage('Cannot delete record because it is closed with high impact.');
        current.setAbortAction(true); 
    }

})(current, previous);
☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

View solution in original post

5 REPLIES 5

James Chun
Kilo Patron

Hi @nafiz435,

 

Unless you are applying some complex logic, there is no need to write a script.

Select Delete and set your condition as per your need, e.g.

JamesChun_0-1720234368736.png

Under the Actions tab, select Abort action. Feel free to add a message if required as well

JamesChun_1-1720234399973.png

 

Cheers