2

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: enter image description here

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?

1 Answer 1

1

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 String
  • BillingCountryCode is a Picklist

You need to reference BillingCountryCode to pull your translated values:

SELECT toLabel(BillingCountryCode) FROM Account

1
  • Thank you so much that did the trick!
    – JohnMay
    Aug 3, 2021 at 14:58

You must log in to answer this question.

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