Validation rule to prevent Revenue Assurance profile users to delete cases unless they are a specific recordtype - Answers - Salesforce Trailblazer Community
Ask Search:
Eric PohlabelEric Pohlabel 

Validation rule to prevent Revenue Assurance profile users to delete cases unless they are a specific recordtype

I have a validation rule designed to prevent users with the Revenue Assurance profile from deleting Case records UNLESS the Case RecordType is of ID "0120f000001NT54". 

THe Validation formula is this:

$Profile.Name = "Revenue Assurance" && 
RecordTypeId <> "0120f000001NT54"

But it doesn't work.  Revenue Assurnace users are still able to delete cases that are not of the specific record type!
Best Answer chosen by Eric Pohlabel
Sunil SarillaSunil Sarilla
Hi Eric,
Generally, you will not be able to  prevent deletion through validation rules.
you will need an apex trigger to do this.
or remove the standard delete button and create a custom delete button which will launch a flow and delete the record if record meets conditions

All Answers

Sunil SarillaSunil Sarilla
Hi Eric,
Generally, you will not be able to  prevent deletion through validation rules.
you will need an apex trigger to do this.
or remove the standard delete button and create a custom delete button which will launch a flow and delete the record if record meets conditions
This was selected as the best answer
Eric PohlabelEric Pohlabel
Thank you!  I will add it to our existing BIAIU trigger on Cases.
Vincent DraderVincent Drader
I've sometimes replaced the standard delete button with a flow screen that either can restrict the delete (just takes them to a "you can't do that" screen), allows the delete if they make changes or are given permission (and then can run certain processes as a result of the delete), or asks for confirmation and outlines the consequences. I find this to be very helpful.