Salesforce Developer Soql I18n


// Salesforce - Developer - SOQL - Translating Results:

Use toLabel(object.field) to translated SOQL query results into the user's 
language.  The toLabel method is particularly useful for organizations that have 
Translation Workbench enabled.

SELECT Company, toLabel(Recordtype.Name) FROM Lead;

We cannot filter on the translated name value from a record type.  We must 
always filter on the master value or the ID of the object for record types.

We can use toLabel() to filter records using a translated picklist value:

SELECT Company, toLabel(Status) FROM Lead WHERE toLabel(Status) = 'le Draft';

The comparison is made against the value for the user's language.  If there is 
no translation available for the user's language for the specified picklist, 
the comparison is made against the master values.

We cannot use the toLabel() method in the ORDER BY clause.  Salesforce always 
uses the picklist's defined order.  Also, we cannot use toLabel() in the WHERE 
clause for division or currency ISO code picklist.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License