+ Start a Discussion

updating Total Price on OpportunityLine Item

Hi Guys,

Hope somebody has come across this and can provide some help.


On the OpportunityLine Item i need to calculate the Total price depending on some formula.

eg: quantity is 1000

      Sales Price is  $ 25

  The customer gets only 50% of the total revenue so i have created a custom field which holds the gross value


The net value is 50% of gross value,which is equal to 12500.


Now i need to capture this Net value in the Total price field of the OpportunityLine Item(since i need the correct value of the deal for forecasting on the opportunity).


I tried doing this using trigger .But it doesnt work.Pls find my code below.



 trigger AC_OpportunitylineitembeforeUpdate on OpportunityLineItem (before insert, before update) {
    List<OpportunityLineItem> opprs = new List<OpportunityLineItem>();
    for (Integer i=0;i<trigger.new.size();i++) {
        if(trigger.new[i].Net_Campiagn_Value__c != null && trigger.new[i].Revenue_Share__c != null){
            trigger.new[i].TotalPrice = (trigger.new[i].Net_Campiagn_Value__c*trigger.new[i].Revenue_Share__c)/100 ;




I also tried this:


trigger AC_OpportunitylineitembeforeUpdate on OpportunityLineItem (before insert, before update) {
    List<OpportunityLineItem> opprs = new List<OpportunityLineItem>();
    for (Integer i=0;i<trigger.new.size();i++) {
        if(MyWebService.UpdateCall == false){



But unfortunetly none of it seems to work .

This link tells me that it can be updated:



But i really dont know how.


If somebody has come across this problem and has found a solution pls help.

Thanks in advance.






Can't you do that with a workflow (field update)? This would be much easier.


What excactly doesn't work? Does the field not get updated at all or with a wrong value?


Thanks micwa for your prompt reply.


Total Price on Opportunity Line Item is calculated internally by salesforce as ( quantity*sales Price) and I am not able to over write that value with my code. It still shows the Original value.


When Using Workflow the Total Price field does not show up in the look up of Fields to update.(understandbly so becuase Total Price is automatically calculated by salesforce).

You can't directly change Total Price, ever. It can only be maninpulated with Unit Price and Quantity. It sounds like what you really need is a seperate formula field called Net Amount which is mearly Total Price / 2.
Message Edited by TehNrd on 06-12-2009 04:24 PM