You need to sign in to do that
Don't have an account?
Haris Sheikh 1
Prevent deletion of opportunity product depending on custom value in a field in OpportunityLineItem
Hi,
I have a scenario to prevent deletion of opportunity products from opportunity if a custom field in OpportunityLineItem table has a specific value.
How can I implement it using using validation rules on Opportunity?
Thanks!
I have a scenario to prevent deletion of opportunity products from opportunity if a custom field in OpportunityLineItem table has a specific value.
How can I implement it using using validation rules on Opportunity?
Thanks!
You can't use Validation Rule to prevent deletion.
You should use a Before Delete Trigger instead.
By adding "addError" on a field, you will abort deletion.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm#highlighter_797812
Please mark this as solution if this will help you
Thanks
Amit Chaudhary
I think the trigger will be needed when deleting a product from its detail page but I want to stop deletion from related list in opportunity page. I am currently doing it through validation rule with this formula: but now I am trying to change this formula to somehow check for a specific value in a custom field in product.
Trigger will work from both place from detail page as well as from releted list. Please try above trigger and let me know this will help you or not