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

Multiplying UnitPrice to match agreed increase.

Hi All,


how would I multiply the unitprice on an opportuniy line item by another field value.


   IF(PE.Product2Id == OL.PricebookEntry.Product2Id){
        NOL = New OpportunityLineItem();
            NOL.Opportunityid =;
            NOL.PricebookEntryId =;
            NOL.Quantity = OL.Quantity;
            NOL.UnitPrice = OL.UnitPrice * IncPer;

 I get


Error: Arithmetic expressions must use numeric arguments


Is this because Incper is:


 String IncPer = '1.' + o.account.Agreed_price_Increase__c;

 In this example IncPer returns 1.10




Best Answer chosen by Admin (Salesforce Developers) 
Eugene NeimanEugene Neiman

Try casting first.


Decimal IncPerAsDec = decimal.valueOf(IncPer);