Skip to Content

Salesforce Certified Platform App Builder: Prevent Deletion of Accounts with Open Opportunities in Salesforce

Learn how to restrict the deletion of accounts with open opportunities in Salesforce using validation rules. Protect your active sales data with this simple solution.

Table of Contents

Question

The Sales Operations team at AW Computing deletes accounts for a variety of reasons. The sales ops director is worried that the Sales team may delete accounts that sales reps are actively selling into.

How should the app builder keep accounts with open opportunities from being deleted?

A. Remove the Delete permission from the Sales Rep profile.
B. Remove the delete button on the account layout.
C. Create an Apex Trigger on the Account object.
D. Create a validation rule on the Account object.

Answer

D. Create a validation rule on the Account object.

Explanation

To prevent the deletion of accounts that have open opportunities, the best approach is to create a validation rule on the Account object. A validation rule can check for the presence of open opportunities and prevent the deletion of the account if any are found.

Here’s how to implement the validation rule:

  1. Navigate to Setup > Object Manager > Account > Validation Rules.
  2. Click “New” to create a new validation rule.
  3. Provide a meaningful name and description for the rule, such as “Prevent Account Deletion with Open Opportunities.”
  4. In the formula editor, enter the following formula: COUNT(Opportunities WHERE IsClosed = false) > 0
  5. Specify an error message to display when the validation rule is triggered, such as “Cannot delete an account with open opportunities.”
  6. Save the validation rule.

With this validation rule in place, whenever a user attempts to delete an account that has one or more open opportunities, Salesforce will display the specified error message and prevent the deletion.

The other options are not suitable for this scenario:

  • Removing the Delete permission from the Sales Rep profile (A) would prevent them from deleting any accounts, even those without open opportunities.
  • Removing the delete button on the account layout (B) would only hide the button but not enforce the restriction.
  • Creating an Apex Trigger on the Account object (C) is an overly complex solution when a validation rule can handle the requirement effectively.

Salesforce Certified Platform App Builder certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Salesforce Certified Platform App Builder exam and earn Salesforce Certified Platform App Builder certification.