Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
amja0d

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

Cheers

micwa

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?

amja0d