function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RommelPeraltaRommelPeralta 

Updating Total Price on OpportunityLine Item after approving a custom field on Opportunity

Hi Guys,


I'm a newbie on Apex code development. Am trying to solve this for days now, I also tried exploring workflow rules and field updates, but I had no success. I hope you can help me with this.

Below is the senario:

 

There are two important custom fields under Opportunity -- Submitted Discount Approval Request & Discount Approved, both of them are checkbox and are uncheked/false by default. 

 

Submitted Discount Approval Request field should be checked before an Opportunity can be submitted for Approval on the Approval History block under the opportunity page. After submission, a new entry on the Approval History block will ask to approve or reject the request. If the manager approves it, the Discount Approved field will become checked/true.

 

Now here's the thing, on the Opportunity products, below are the fields,

Action            Product                                 Quantity Sales Price Discount Amount Total Price Date Line Description

Edit |  DelGenWatt Diesel 1000kW2.00$100,000.00$20,000.00 $200,000.00

 

 

If the Opportunity Discount Approved field becomes checked/true, the Total Price field of Opportunity Products(s) should automatically be updated based on (Total Price - Discount Amount). What happens now is, I need to edit and save the Opportunity product before the changes could take effect.

 

To make the story short, the Total Price should automatically become $180,000.00 after the Discount Approved field of the Opportunity has been checked/true -- this happens when the Submit for Approval is Accepted by the Approver.


Thanks in advance.