ALLVERSIONS & LATESTVERSION
By default, a query on the documents object targets the latest version of all documents. In v8.0+, you can query by document version:
- Use
ALLVERSIONSwithFROMto query all document versions. - Use
LATESTVERSIONwithSELECTandALLVERSIONSto retrieve the latest version that matches theFINDorWHEREsearch criteria.LATESTVERSIONon its own uses the default behavior.
Syntax
Section link for SyntaxSELECT LATESTVERSION {fields}
FROM ALLVERSIONS documentsQuery Examples
Section link for Query ExamplesThe following are examples of queries using ALLVERSIONS and LATESTVERSION.
Query: ALLVERSIONS
Section link for Query: ALLVERSIONSThe following query returns the ID and major and minor version numbers of all document versions:
SELECT id, major_version_number__v, minor_version_number__v
FROM ALLVERSIONS documentsResponse: ALLVERSIONS
Section link for Response: ALLVERSIONS{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 3,
"total": 3
},
"data": [
{
"id": 6,
"major_version_number__v": 1,
"minor_version_number__v": 1
},
{
"id": 6,
"major_version_number__v": 1,
"minor_version_number__v": 0
},
{
"id": 5,
"major_version_number__v": 0,
"minor_version_number__v": 1
}
]
}Query: LATESTVERSION
Section link for Query: LATESTVERSIONIn this example, a user has assigned a value to the Country field in a document with version 1.1. The following query returns the latest version of this document where the Country field is empty:
SELECT LATESTVERSION id, major_version_number__v, minor_version_number__v
FROM ALLVERSIONS documents
WHERE id = 6 AND country__c = NULLResponse: LATESTVERSION
Section link for Response: LATESTVERSION{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 1,
"total": 1
},
"data": [
{
"id": 6,
"major_version_number__v": 1,
"minor_version_number__v": 0
}
]
}