function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
manuel-jose-condemanuel-jose-conde 

retrieve Currency name

how can we retrieve in a SOQL statement the currency name? (not the isoCode)

micchrismicchris

As far as I know, not through SOQL, but...

 

You'll need to do some introspection on the currency field. Read about DescribeSObjectResult and more specifically the PicklistEntry object, which has a getLabel() method. The code snippet below is from a class where I display the available curriencies of a currency field as a bullet list on a VF page (hence the HTML).

 

String descr;
if (fieldDescr.getType() == Schema.Displaytype.Picklist || fieldDescr.getType() == Schema.Displaytype.MultiPicklist) {
	descr = 'Picklist values:';
	for (Schema.PicklistEntry picklistEntry : fieldDescr.getPicklistValues()) {
		descr += '<br />&nbsp;&bull;&nbsp;';
		descr += picklistEntry.isDefaultValue() 
			? '<em>' + picklistEntry.getValue() + ' ' + picklistEntry.getLabel() + '</em>'
			: picklistEntry.getValue() + ' ' + picklistEntry.getLabel();
	}
}

 

Hope that brings you a little further.

manuel-jose-condemanuel-jose-conde

many thanks for your answer.

I was thinking if I could avoid to use metadata api. I know I can use  "toLabel" SOQL built-in function and that would work fine:

SELECT toLabel(IsoCode) from DatedConversionRate 

 

(you need to have translation workbench enabled to have toLabel working)

 

but obviously it works only with picklist fields and CurrencyIsoCode, that is present in all objects is not a picklist type field so if I want to translate isocode (I mean to get isocode translated to the currency name) through a SOQL statement....It seems not possible...