Newer Version Available
toLabel()
To translate SOQL query results into the language of the user who submits the query,
use the toLabel method.
Any organization can use the toLabel() method.
The toLabel method uses the following syntax:
1toLabel(object.field)Use this method to return translated search results on:
- Regular, multiselect, division, or currency code picklist fields, whose values are returned by the relevant describe API call.
- Data category group and data category unique name fields.
- Recordtype names.
- Object History. HISTORY is supported on a limited basis. When a tracked field changes, the clause SELECT toLabel(Field) FROM *History returns the primary label of the changed field or the existing translated label. OldValue and NewValue fields in history objects also support the toLabel method, but the query returns translated values for only tracked changes on supported field types.
1SELECT Company, toLabel(Recordtype.Name) FROM LeadThe returned records are translated into the language of the user who issued the query.
You can use the toLabel() method to filter records using a translated picklist value. For example:
1SELECT Company, toLabel(Status)
2FROM Lead
3WHERE toLabel(Status) = 'le Draft'The query returns lead records with a picklist value for Status equal to 'le Draft.' The comparison is made against the value for the user’s language. If no translation is available for the picklist, the comparison is made against the master values.
The following limitations apply to translated picklist values:
- The LIKE operator can only query on the label of the picklist, not on its API name.
- You can’t use the toLabel() function with the operator ORDER BY. SOQL always uses the picklist’s defined order.
- You can’t use the toLabel()function in a WHERE clause for division or currency ISO code picklists.