+ Start a Discussion
p1 force developerp1 force developer 

How to get currency value in corporate currency

We have multi-currency feture enabled.

 


We have several custom objects for documents like sales order, sales quote, ap invoice ,where values  are stored in the local exhange rate.  GBP, EUR, CHF etc. and the corporate currency is set as USD.
 
I need to be able to record an amount (in a new field) in USD
 
Does anyone have a solution to get values for a currency feild in its curporate currency value.

 

I have trieid using convertCurrency in the select statements but it returns the values in user's currency.

 

I want to know, how do we get the values in corporate currency for any  currency field value.

 

Thanks


Best Answer chosen by Admin (Salesforce Developers) 
ministe2003ministe2003

When exchange rates are updated they're stored in the CurrencyType object, so do something like this:

 

list<CurrencyType> c = [SELECT ISOCode, ConversionRate FROM CurrencyType WHERE IsActive=TRUE];

 

So you have a list of currently active currencies and their exchange rate.  To get currency values into your org's currency, just divde the value by that currency's exchange rate.  for example:

 

for(integer i = 0; i< c.size(); i++){
if(Opp.CurrencyISOCode == c[i].ISOCode){
convertedCurrency = Opp.Amount / c[i].ConversionRate;
}
}

 

All Answers

mtbclimbermtbclimber

You'll have to perform the conversion yourself by getting the org's exchange rates from the CurrencyType object in the API.

p1 force developerp1 force developer

Thanks Andrew,

 

Can you provide some sample code to get the value of amount feilds  in corporate currency.

 

 

ministe2003ministe2003

When exchange rates are updated they're stored in the CurrencyType object, so do something like this:

 

list<CurrencyType> c = [SELECT ISOCode, ConversionRate FROM CurrencyType WHERE IsActive=TRUE];

 

So you have a list of currently active currencies and their exchange rate.  To get currency values into your org's currency, just divde the value by that currency's exchange rate.  for example:

 

for(integer i = 0; i< c.size(); i++){
if(Opp.CurrencyISOCode == c[i].ISOCode){
convertedCurrency = Opp.Amount / c[i].ConversionRate;
}
}

 

This was selected as the best answer
Alex K.Alex K.

Can you think of any way to achieve this using formulas? I have a need to use/expose (only) the corporate currency for use in in standard Salesforce reports. 

 

While the corporate currency amount is displayed in parenthesis next to the foreign currency, accessing the corporate currency value for formula work or reports is a real challenge. Unless I've missed something...?

 

Thanks much.