Translate SOQL Query Results
Any organization can use the toLabel() method. It’s useful for organizations that enabled the data translation. For information on how to enable data translation, see Manage Entities’ Data Translation in Salesforce Scheduler Help.
The toLabel method uses the following syntax:
toLabel(object.field)
- Name
- Description
- Custom fields of type Text, MultiLine Text, Long Text Area, Rich Text Area, and URL
You can’t use the toLabel() method in the ORDER BY clause. For limitations that apply to the translation, see Translate Returned SOQL Results in SOQL and SOSL Reference.
- Sample Request
-
Example of data translation request for WorkTypeGroup:
https://yourInstance.salesforce.com/services/data/vXX.X/ query/?q=SELECT+toLabel(Name),+toLabel(Description),+toLabel(Details__c),+toLabel(Disclaimer__c)+From+WorkTypeGroup
-
Example of data translation request for ServiceResource:
https://yourInstance.salesforce.com/services/data/vXX.X/ query/?q=SELECT+toLabel(Name),+toLabel(Description),+toLabel(Profile_URL__c)+From+ServiceResource
-
Example of data translation request for ServiceTerritory:
https://yourInstance.salesforce.com/services/data/vXX.X/ query/?q=SELECT+toLabel(Name),+toLabel(Description),+toLabel(Notes__c)+From+ServiceTerritory
- Sample Response
-
Example of translated query results for WorkTypeGroup:
{ "totalSize": 6, "done": true, "records": [ { "attributes": { "type": "WorkTypeGroup", "url": "/services/data/v54.0/sobjects/WorkTypeGroup/0VSx00000000ZTDGA2" }, "Name": "手術", "Description": "説明", "Details__c": "<ul><li><b><i><u>これはテキスト領域です</u></i></b><span style=\"color: rgb(0, 0, 0);\"></span></li></ul>", "Disclaimer__c": "信頼" }, { "attributes": { "type": "WorkTypeGroup", "url": "/services/data/v54.0/sobjects/WorkTypeGroup/0VSx00000000ZTAGA2" }, "Name": "WTG 3", "Description": null, "Details__c": null, "Disclaimer__c": null } ] }
-
Example of translated query results for ServiceResource:
{ "totalSize": 2, "done": true, "records": [ { "attributes": { "type": "ServiceResource", "url": "/services/data/v54.0/sobjects/ServiceResource/0Hnx000000003I6CAI" }, "Name": "Адам Смит", "Description": "описание", "Profile_URL__c": "http:// профиль" }, { "attributes": { "type": "ServiceResource", "url": "/services/data/v54.0/sobjects/ServiceResource/0Hnx000000003I9CAI" }, "Name": "Stacy Simon", "Description": null, "Profile_URL__c": null } ] }
-
Example of translated query results for ServiceTerritory:
{ "totalSize": 2, "done": true, "records": [ { "attributes": { "type": "ServiceTerritory", "url": "/services/data/v54.0/sobjects/ServiceTerritory/0Hhx00000000c9tCAA" }, "Name": "l'apollon", "Description": "à la mode", "Notes__c": "française" }, { "attributes": { "type": "ServiceTerritory", "url": "/services/data/v54.0/sobjects/ServiceTerritory/0Hhx00000000cgaCAA" }, "Name": "tempST", "Description": null, "Notes__c": null } ] }