Trying to write trigger on Order item .I have created new field called discount.I have to perform formula using trigger on TotalPrice(TotalPrice=Discount*TotalPrice).I am not able to access TotalPrice hence getting this error "Innvalid field TotalPrice for SObject OrderItem " Not understanding how to access TotalPrice fields .

 trigger Totalprice on OrderItem (after insert,after update)  {
      if(trigger.isafter && trigger.isupdate){
           for(OrderItem oi : trigger.new) {
               Oi.TotalPrice=  Oi.Discount__c*Oi.TotalPrice;

1 Answer 1


The TotalPrice field is not available in OrderItem object it is being calculated

OrderItem.TotalPrice = OrderItem.UnitPrice * OrderItem.Quantity

so query for the quantity and unitprice and use above formula.

Hope this helps you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .