Skip to content

Functions & Options

Use query functions and query target options to modify returned values or refine your search by bypassing default query behavior.

If a document field is included twice, both by itself and modified by a function, you must define an alias for the function. When querying objects, you can only create an alias with the LONGTEXT() and RICHTEXT() functions.

These options are specifically for querying the documents target and managing version or lifecycle state visibility.

NameSyntaxDescriptionAPI Version
ALLVERSIONSSELECT {field} FROM ALLVERSIONS documentsRetrieve fields from all document versions. Can only be used when querying documents.v8.0+
DELETEDSTATE()WHERE status__v = DELETEDSTATE()Retrieve fields from all documents in a steady, obsolete, superseded, or deleted state. Can only be used when querying documents.v19.2+
OBSOLETESTATE()WHERE status__v = OBSOLETESTATE()Retrieve fields from all documents in a steady, obsolete, superseded, or deleted state. Can only be used when querying documents.v8.0+
STEADYSTATE()WHERE status__v = STEADYSTATE()Retrieve fields from all documents in a steady, obsolete, superseded, or deleted state. Can only be used when querying documents.v8.0+
SUPERSEDEDSTATE()WHERE status__v = SUPERSEDEDSTATE()Retrieve fields from all documents in a steady, obsolete, superseded, or deleted state. Can only be used when querying documents.v8.0+
LATESTVERSIONSELECT LATESTVERSION {field} FROM ALLVERSIONS documentsRetrieve fields from the latest matching version. Can only be used when querying documents.v8.0+

These options are used exclusively within the FIND clause to narrow the search area across documents or objects.

NameSyntaxDescriptionAPI Version
SCOPE ALLFIND ('{search phrase}' SCOPE ALL)Search all fields and document content.v8.0+
SCOPE CONTENTFIND ('{search phrase}' SCOPE CONTENT)Search document content only.v8.0+
SCOPE {fields}FIND ('{search phrase}' SCOPE {fields})Search one specific document field or up to 25 object fields.v15.0+
SCOPE PROPERTIESFIND ('{search phrase}' SCOPE PROPERTIES)Search all picklists and document or object fields with data type String. This is the default scope.v8.0+

These options filter results based on the currently authenticated user's interactions in Vault.

NameSyntaxDescriptionAPI Version
FAVORITESSELECT {fields} FROM FAVORITES {query target}Filter results to those the currently authenticated user has marked as a favorite.Documents: v22.2+

Vault objects: v23.2+
RECENTSELECT {fields} FROM RECENT {query target}Filter results to the 20 documents or object records the currently authenticated user has viewed most recently (in descending order by date).Documents: v22.2+

Vault objects: v23.2+

These functions allow for the retrieval of metadata from files stored in Attachment type fields (available in v24.3+).

NameSyntaxDescriptionAPI Version
FILENAME()SELECT FILENAME({field}) FROM {query target}
WHERE FILENAME({field}) {operator} {value}
FIND ('{search phrase}' SCOPE FILENAME({field}))
ORDER BY FILENAME({field})
Use the file name of an Attachment field file instead of the file handle.v24.3+
FILESIZE()SELECT FILESIZE({field})Retrieve the file size, MIME type, or MD5 checksum of an Attachment field file.v24.3+
MIMETYPE()SELECT MIMETYPE({field})Retrieve the file size, MIME type, or MD5 checksum of an Attachment field file.v24.3+
MD5CHECKSUM()SELECT MD5CHECKSUM({field})Retrieve the file size, MIME type, or MD5 checksum of an Attachment field file.v24.3+

These functions modify how field values are compared or returned in the result set.

NameSyntaxDescriptionAPI Version
CASEINSENSITIVE()WHERE CASEINSENSITIVE({field}) {operator} {value}Bypass case sensitivity of fields in the WHERE clause.v14.0+
LONGTEXT()SELECT LONGTEXT({field}) FROM {query target}Retrieve the full value of a Long Text fieldv17.1+
RICHTEXT()SELECT RICHTEXT({field}) FROM {query target}Retrieve the full Rich Text field value with HTML markup.v21.1+
STATETYPE()WHERE state__v = STATETYPE('{state_type}')Retrieve object records in a specific object state type.v19.3+
TODISPLAYFORMAT()SELECT TODISPLAYFORMAT({field}) FROM {query target}With SELECT, retrieve a field’s formatted value instead of the raw value.v23.2+
TOLABEL()SELECT TOLABEL({field}) FROM {query target}

WHERE TOLABEL({field}) {operator} {value}
With SELECT, retrieve the object field label instead of the name.

With WHERE, filter by the object field label instead of the name.
v24.1+
TONAME()SELECT TONAME({field}) FROM documents

WHERE TONAME({field}) {operator} {value}
With SELECT, retrieve the document field name instead of the label.

With WHERE, filter by the document field name instead of the label.
v20.3+