SCOPE Fields
In v15.0+, use SCOPE {field} to search a specific document field or Vault object field.
In v22.3+, use SCOPE {fields} to search multiple fields when querying Vault objects, up to a maximum of 25 fields.
When querying Vault objects, SCOPE {fields} supports fields of data type String (Text, LongText, and RichText fields) and object reference fields.
When querying documents, SCOPE {field} only supports fields of data type String (Text, LongText, and RichText fields).
In v25.3+, you can use a single SCOPE {field} operation with one single-value object or document reference field lookup. For example, FROM documents FIND ('cholecap' SCOPE obj_ref__cr.name__v). On documents, you can use SCOPE {field} on a lookup but not on the object reference field directly.
SCOPE does not support picklist fields. To query picklist fields, use SCOPE ALL or SCOPE PROPERTIES.
Syntax
Section link for SyntaxSELECT {fields}
FROM {query target}
FIND ('{search phrase}' SCOPE {field_1, field_2})Query Examples
Section link for Query ExamplesThe following are examples of queries using SCOPE {fields}.
Query: Search a Specific Document Field
Section link for Query: Search a Specific Document FieldThe following query searches the name__v document field for the search term insulin. You can only include one document field.
SELECT id, name__v
FROM documents
FIND ('insulin' SCOPE name__v)Query: Search a Specific Object Field
Section link for Query: Search a Specific Object FieldThe following query searches the name__v and generic_name__vs object fields for the search term phosphate:
SELECT id, name__v
FROM product__v
FIND ('phosphate' SCOPE name__v, generic_name__vs)Query: Combining SCOPE Fields with SCOPE CONTENT
Section link for Query: Combining SCOPE Fields with SCOPE CONTENTThe following query returns all documents where the name contains the search term cholecap and the document content also contains prescribing or information:
SELECT id, name__v
FROM documents
FIND ('cholecap' SCOPE name__v AND 'prescribing information' SCOPE CONTENT)Query: Combining FIND with WHERE
Section link for Query: Combining FIND with WHEREWhen using FIND with or without SCOPE, you can use the WHERE clause to narrow results. WHERE must be placed after FIND and SCOPE. The following query searches the generic_name__vs field for the search term phosphate in all Product records with a specific therapeutic area:
SELECT id, name__v
FROM product__v
FIND ('phosphate' SCOPE generic_name__vs)
WHERE therapeutic_area__vs = 'cardiology__vs'Query: Search a Related Document Using a Lookup
Section link for Query: Search a Related Document Using a LookupThe following query returns Product records where the term cholecap appears in the name__v field of Materials (materials__c) related document:
SELECT id, name__v, materials__c
FROM product__v
FIND ('cholecap' SCOPE materials__cr.name__v)