Salesforce Fact #634 | Validation on opportunity deletion

Suppose we need to keep a validation on Opportunity, an opportunity cannot be deleted if it has existing line items.

We can make use of the HasOpportunityLineItem field in trigger.

Attached is the screenshot.



Note: The code snippet is only for demonstration purpose and apex best practices have not been covered.

Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow