2

I have a requirement where I need to display the currency along with price, but the issue is that in my org i have enabled multi currencies, so I want to get the ISO code for that particular record.

For example, I have a order say 'A' whose product price is $20, I have another order say 'B' whose product price is GBP 10. I want to display this info on a Visual force page where the currency will depend on order type. Can anyone help me how to get the ISO code using query for a particular field.

Thanks in advance.

3

{!object.CurrencyISOCode} will give you the ISO code for that record.

I believe you can use {!Label[object.CurrencyISOCode]} to get the symbol, but I'm not 100% sure. That could always be done in a case formula once you have the ISO Code.


edit

I haven't tested this but something along these lines this should work if you have to include ISO Code in a query.

Object__c obj = [SELECT Whatever__c FROM Object__c WHERE Id = :someid];
String currencyCode = obj.get("CurrencyIsoCode");

Also... a bit ugly, but you can build a formula field (text) on the object "CurrencyIsoCode" and then it should behave just like any other field in queries, page layout, etc.

  • Hello, I am trying to use the above thing but its not working. Can you please post the query so that I can learn. I wrote the query as String str=(String)[select isocode from currencytype where isocode=orderitem.CurrencyISOCode limit 1]; is this right? – Praveen Biyani May 30 '15 at 6:39
  • Firstly I want the to query the ISO code using Apex then display it – Praveen Biyani May 30 '15 at 6:48
  • updated my answer. good luck... – RyanP May 30 '15 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.