You need to sign in to do that
Don't have an account?
Tejaswini Lambe
AfterDelete trigger on opportunitylineitem
Hi Team,
I want to write a trigger on delete of opportunity line items. I have a following requirement:
Opportunity Fields: Approval Status, Discount
If an opportunity line item is deleted, when the opportunity approval status is approved, and deletion results in increase in discount (compared to discount before deleting opportunitylineitem), the opportunity approval status should be chnaged to 'Unapproved.'
I need immediate help. Any pointers/feedback are appreciated.
I want to write a trigger on delete of opportunity line items. I have a following requirement:
Opportunity Fields: Approval Status, Discount
If an opportunity line item is deleted, when the opportunity approval status is approved, and deletion results in increase in discount (compared to discount before deleting opportunitylineitem), the opportunity approval status should be chnaged to 'Unapproved.'
I need immediate help. Any pointers/feedback are appreciated.
In the trigger, query the related Opportunity records for the deleted OpportunityLineItems using the OpportunityId field.
Iterate through the queried Opportunity records and check if the Approval Status is 'Approved'.
If the Approval Status is 'Approved', compare the Discount value of the OpportunityLineItem being deleted with the existing Discount value on the Opportunity.
If the Discount value of the OpportunityLineItem being deleted is greater than the existing Discount value on the Opportunity, update the Approval Status of the Opportunity to 'Unapproved'.
Save the modified Opportunity records. https://www.mykfcexperience.website/
Please try with the below code and let me know if you have any further questions ahead .
If this helps , please mark this as Best Answer.
Thank you.