function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ahonahon 

how to prevent record deletion based on a condition

Is there a way to prevent record deletion based on, for example, a status field without using code?
Best Answer chosen by ahon
DishantDishant (Salesforce Developers) 
Hi Ahon,

Please find the below articles which might help you! 

https://developer.salesforce.com/forums/?id=9062I000000g5mEQAQ 

Using Flow to Prevent Record Deletion (https://salesforcetime.com/2023/09/03/using-flow-to-prevent-record-deletion/#:~:text=1%2D%20Create%20a%20record%2Dtriggered,flow%20should%20look%20like%20this.

Please mark this as a best answer if this was useful. Thank you! 

Important Update - what you need to do

As a reminder, on December 4, 2023 the Salesforce Discussion Forums will be removed from the Salesforce Developers website. These forums will shut down and all relevant discussions will migrate to the Trailblazer Community digital platform.

During the week starting November 20, you can view discussions, but not post new questions or responses. On December 4, you will no longer be able to access the discussion forums from the Salesforce Developers website.

Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
  1. If you’re not already a member of the Trailblazer Community, sign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
  2. If you already have a Trailblazer account, and it’s using a different email address from your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Find more info & support
We know that moving platforms can be a hassle, so we created a special forums users group, the Migration Support Hub, in the Trailblazer Community where you can get training videos, information, and assistance.

We are here to help you through this transition!

Sincerely,
The Forums Support Team
 

All Answers

DishantDishant (Salesforce Developers) 
Hi Ahon,

Please find the below articles which might help you! 

https://developer.salesforce.com/forums/?id=9062I000000g5mEQAQ 

Using Flow to Prevent Record Deletion (https://salesforcetime.com/2023/09/03/using-flow-to-prevent-record-deletion/#:~:text=1%2D%20Create%20a%20record%2Dtriggered,flow%20should%20look%20like%20this.

Please mark this as a best answer if this was useful. Thank you! 

Important Update - what you need to do

As a reminder, on December 4, 2023 the Salesforce Discussion Forums will be removed from the Salesforce Developers website. These forums will shut down and all relevant discussions will migrate to the Trailblazer Community digital platform.

During the week starting November 20, you can view discussions, but not post new questions or responses. On December 4, you will no longer be able to access the discussion forums from the Salesforce Developers website.

Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
  1. If you’re not already a member of the Trailblazer Community, sign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
  2. If you already have a Trailblazer account, and it’s using a different email address from your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Find more info & support
We know that moving platforms can be a hassle, so we created a special forums users group, the Migration Support Hub, in the Trailblazer Community where you can get training videos, information, and assistance.

We are here to help you through this transition!

Sincerely,
The Forums Support Team
 
This was selected as the best answer
ahonahon
@dishant both refer to an apex trigger -- is there a no-code option?
DishantDishant (Salesforce Developers) 
Hi Ahon,

The second link i.e. https://salesforcetime.com/2023/09/03/using-flow-to-prevent-record-deletion/#:~:text=1%2D%20Create%20a%20record%2Dtriggered,flow%20should%20look%20like%20this. 
Is a soultion with Salesforce Flow. The Trigger and class mentioned in the start of the webpage is only to show what the exact task is. 

Thank you!
ahonahon
@dishant do you know if there is an option to eliminate the salesforce standard message that pops up?
i.e 'Are you sure you want to delete this SGI Cancellation Request?' if user clicks delete only then the custom error message pops up.

is there an option to diable or hide delete button completely if record exists?