You need to sign in to do that
Don't have an account?
Rohit Vaidya 3
trigger to prevent deletion
I need to write a trigger to prevent the deletion of account records
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
try this code below
I bet it will look better if so:
trigger PreventDelete on Account (before delete) {
if(Trigger.isBefore && Trigger.isDelete){
for(Account acc : Trigger.old){
acc.addError('Cannot delete account records');
}
}
}
If you find my answer helpful, please mark it as the best answer. Thanks!
If you want to delete an account with active cases, you will need to first close all the associated cases. Once the cases are closed, you can delete the account record. You can also consider writing a custom Apex method or Visualforce page to automate this process and ensure that all associated cases are closed before the account is deleted.
Try with below trigger :
If it helps , please mark this as Best Answer.
Thank you.