Posts

Showing posts with the label HasOpportunityLineItem

Salesforce Fact #640 | At least one line item

Image
Suppose once an opportunity is added with a related opportunity line item, it needs to have at least one line item from then on. We cannot delete all the related line items. We can implement the same using the HasOpportunityLineItem field in a validation rule. Attached is the screenshot.

Salesforce Fact #634 | Validation on opportunity deletion

Image
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.

Salesforce Fact #605 | HasOpportunityLineItem LWC

Image
Similar to using in Flow, Validation rules, SOQLs, HasOpportunityLineItem field can be used in LWC as well to detect whether the opportunity has any line item associated. Attached is the screenshot.