I'm querying an Account Address and want the country to be translated into the language of the requesting user.
Sample query:
SELECT BillingAddress FROM Account
I maintained the translation of the country in the translation workbench and already tried to use "toLabel(BillingAddress)" without success.
When referencing the BillingCountry directly I get the same result. Prefixing with "toLabel" results in an error:
MALFORMED_QUERY: only picklist fields, field history, or platform entity fields (or Record Type Name, Description in the SELECT list) support translation
Within the UI the Label is translated:
Other values in the query are getting translated as well.
Can country and state values be retrieved in the local language using SOQL?
What am I missing?
Is the Country/State picklist not treated as a picklist as referenced in the documentation?
Best Answer
As the error hints, what you're pulling (
BillingCountry
) is not a picklist. If you take a look at the Address Compound Fields documentation, you'll see the following noted:BillingCountry
is a StringBillingCountryCode
is a PicklistYou need to reference
BillingCountryCode
to pull your translated values:SELECT toLabel(BillingCountryCode) FROM Account