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
amja0damja0d 

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

25*1000=25000

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){
            MyWebService.OpportunityLineItemAmount(trigger.new[i]);
        }
    }
}

 

 

But unfortunetly none of it seems to work .

This link tells me that it can be updated:

http://www.salesforce.com/us/developer/docs/sforce70/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sforceAPI_WWHelp&file=sforce_API_objects_OpportunityLineItem.html

 

But i really dont know how.

 

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

Thanks in advance.

Cheers

 

 

 

micwamicwa

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?

amja0damja0d

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

TehNrdTehNrd
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