TONAME()
By default, queries on documents use field labels instead of field names. In v20.3+, use the TONAME() function to use the field name when querying document fields:
- Use
TONAME()withSELECTto retrieve the field name instead of the field label. - Use
TONAME()withWHEREto provide the field name as the filter value.
You can only use TONAME() in documents queries on the following document fields:
- Document lifecycle (
lifecycle__v) - Document lifecycle state (
status__v) - Type (
type__v) - Subtype (
subtype__v) - Classification (
classification__v) - All document
Picklisttype fields
Syntax
Section link for SyntaxSELECT TONAME({field})
FROM {query target}
WHERE TONAME({field}) {operator} {value}The {field} parameter must be the name of one of the supported fields.
Query Examples
Section link for Query ExamplesThe following are examples of queries using TONAME().
The following query filters by the status__v field name and returns both the field name and label:
SELECT TONAME(status__v) AS StatusName, status__v
FROM documents
WHERE TONAME(status__v) = 'draft__c'Response
Section link for Response{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 3,
"total": 3
},
"data": [
{
"StatusName": "draft__c",
"status__v": "Draft"
},
{
"StatusName": "draft__c",
"status__v": "Draft"
},
{
"StatusName": "draft__c",
"status__v": "Draft"
}
]
}