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
randombardrandombard 

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 = op.id;
            NOL.PricebookEntryId = PE.id;
            NOL.Quantity = OL.Quantity;
            NOL.UnitPrice = OL.UnitPrice * IncPer;
            NLI.add(NOL);
        }
    }

 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

 

R

 

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

Try casting first.

 

Decimal IncPerAsDec = decimal.valueOf(IncPer);