0

I have a situation in a multi currency org. I have Booking Object as child related to Opportunity Object. On a Visualforce page I want to show list of Bookings related to the a Opportunity.

Problem : Booking object has a Amount field which can be of any currency. My requirement is, irrespective of Booking record's currency I want to show all the bookings according to the currency of Opportunity(Parent) on a page.

I have tried the convertCurrency(field) function but it is converting according to user's currency which is not suitable for my requirement.

Any help would be much appreciated.

2
  • 1
    can you add some code or query you had so far?
    – Anurag
    Jul 7, 2016 at 13:55
  • Select Id, Name, Opportunity__r.Amount, Opportunity__r.Id, Opportunity__r.CurrencyIsoCode, Amount__c from BookingObject__c WHERE Opportunity__r.CurrencyIsoCode != 'USD'
    – abhi
    Jul 7, 2016 at 18:06

1 Answer 1

1

As you noted, SOQL convertCurrency() converts to the users currency, not some arbitrary currency (in your case, the parent Opportunity's currency).

To do this is going to require a VF controller that exploits either the DatedConversionRate SObject, if using Advanced Currency Management or the CurrencyType SObject if not.

As conversion rates are defined against the org currency, and Opportunity currency is not necessarily org currency, you will have to do two operations:

  • Convert Booking amount to Org currency and then ..
  • Divide the result by the Opportunity currency-to-Org currency rate

If using DatedConversionRate; choose Opportunity.ClsoeDate as the date to use to look up the proper rate.

You must log in to answer this question.

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