Salesforce – How to get translated values of picklist and Record Types in Apex?

When we create an application that uses multiple languages, we use translation workbench is the purpose of the translation. Salesforce takes care of the translation user interface, so we always got the right language. But to get the data (picklist values and record type names) in the appropriate language in Apex and VisualForce – we have to do it ourself.

To do this use the command toLabel() in SOQL query.

SELECT Name, toLabel(Industry), toLabel(RecordType.Name) FROM Account

The official documentation says: A client application can have results from a query returned that are translated into the user?s language, using toLabel()

Leave a Reply

Your email address will not be published. Required fields are marked *