1

I have enabled multiple currencies in my EE production Org. Advanced Currency Management is also enabled. I am using Manage Dated exchange rate. USD is my corporate currency. User currency is also in USD. I want to show the conversion of USD to GBP on my visualforce page. It will be like this

$2240*(Conversion rate of GBP that is 0.76) = Converted Amount(GBP)

Where, $2240 is static Value. I want to take this conversion rate(0.76) in Visualforce Page to show its multiplication with static value to get converted rate in GBP. How can we take this conversion rate(0.76) on visualforce page?

Class

public class myExchangeRateController { 

    private final CurrencyType rate; 

    public myExchangeRateController(){ 
        rate = ([Select Id, ConversionRate From CurrencyType Where IsoCode = 'GBP']); 
    } 
    public CurrencyType getRate() { 
        return rate; 
    } 
}
3
  • have you tried select ConversionRate from CurrencyType where IsoCode = 'GBP' Aug 2, 2016 at 5:15
  • public class myExchangeRateController { private final DatedConversionRate rate; public myExchangeRateController() { rate = ([SELECT ConversionRate FROM DatedConversionRate WHERE IsoCode = 'GBP' ]); } public DatedConversionRate getRate() { return rate; } } VF Code:
    – Utkarsha P
    Aug 2, 2016 at 5:22
  • public class myExchangeRateController { private final DatedConversionRate rate; public myExchangeRateController() { rate = ([Select Id, ConversionRate From CurrencyType Where IsoCode = 'GBP' ]); } public DatedConversionRate getRate() { return rate; } } Now my code is like this. I am getting error r: Compile Error: Illegal assignment from List<CurrencyType> to DatedConversionRate at line 5 column 8
    – Utkarsha P
    Aug 2, 2016 at 5:35

2 Answers 2

0

There is a "CurrencyType" object and you can query via SOQL.

The SOQL would look something like:

Select Id,ConversionRate From CurrencyType Where IsoCode = 'GBP'

For more details, refer the link:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_currencytype.htm

1
  • is this right?public class myExchangeRateController { private final CurrencyType rate; public myExchangeRateController() { rate = ([Select Id, ConversionRate From CurrencyType Where IsoCode = 'GBP']); } public CurrencyType getRate() { return rate; } }
    – Utkarsha P
    Aug 2, 2016 at 5:44
0

Thank you all. Its working now. Here i am posting my code.

Apex Class:

public class myExchangeRateController {
 private final CurrencyType rate;

    public myExchangeRateController() {
       rate = ([Select Id, ConversionRate From CurrencyType Where IsoCode = 'GBP']);
    }

    public CurrencyType getRate() {
        return rate;
    }

}

VF Code:

<apex:outputfield value="{!rate.ConversionRate}" />

You must log in to answer this question.

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