+ Start a Discussion
Indira Reddy 1Indira Reddy 1 

How to convert currency to decimal

Hi All,
I am new to Apex and trying to convert Euro to USD and save it in a custom field 'measure'. Here is my code-
CurrencyType conversionRate = [SELECT conversionrate from currencytype where isocode = 'Eur'];
 newProduct.measure__c.= opplineItem.Price / (conversionRate);  
I get the following error 'Arithmetic expressions must use numeric arguments'. I need to convert conversionRate to decimal. Is there anything like integer.valueof() to convert to decimal.
Thank you
Best Answer chosen by Indira Reddy 1
Danish HodaDanish Hoda
Hi Indira,
please use newProduct.measure__c.= opplineItem.Price / (conversionRate.conversionrate);  

All Answers

Danish HodaDanish Hoda
Hi Indira,
please use newProduct.measure__c.= opplineItem.Price / (conversionRate.conversionrate);  
This was selected as the best answer
Indira Reddy 1Indira Reddy 1
Hi Danish, it worked! Thank you!