• amja0d
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

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