SEL_ContentVersion
Class · Group: Selectors
Learn it: Fast Start - Selectors and Selectors guide
global inherited sharing class SEL_ContentVersion extends SEL_BaseExtends: SEL_Base
Selector for the ContentVersion object. Provides query methods for retrieving content versions by publishing location, content document, and workspace folders.
Example
List<ContentVersion> versions = new SEL_ContentVersion().findByFirstPublishLocationId(recordId);
List<ContentVersion> latest = new SEL_ContentVersion().findLatestByContentDocumentId(documentIds);
ContentVersion version = (ContentVersion)new SEL_ContentVersion().findById(versionId);See Also: SEL_Base
Methods
| Method | Description |
|---|---|
| global List<ContentVersion> findByFirstPublishLocationId(Id firstPublishLocationId) | Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId. |
| global List<ContentVersion> findByFirstPublishLocationId(Set<Id> firstPublishLocationIds) | Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId values. |
| global List<ContentVersion> findLatestByContentDocumentId(Set<Id> contentDocumentIds) | Retrieves the latest ContentVersion records for the specified ContentDocument IDs. |
| global List<ContentVersion> getAll() | Retrieves all ContentVersion records in the system. |
| global override List<SObjectField> getFields() | Returns the default fields for ContentVersion queries. |
findByFirstPublishLocationId
global List<ContentVersion> findByFirstPublishLocationId(Id firstPublishLocationId)Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId.
Parameters
| Parameter | Type | Description |
|---|---|---|
firstPublishLocationId | Id | The ID of the location where the content version was first published. |
Returns ContentVersion — List of the latest ContentVersion records associated with the specified location.
Example
List<ContentVersion> result = instance.findByFirstPublishLocationId(recordId);global List<ContentVersion> findByFirstPublishLocationId(Set<Id> firstPublishLocationIds)Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId values.
Parameters
| Parameter | Type | Description |
|---|---|---|
firstPublishLocationIds | Set | Set of IDs for the locations where the content versions were first published. |
Returns ContentVersion — List of ContentVersion records found for the specified locations.
Example
List<ContentVersion> result = instance.findByFirstPublishLocationId(recordIds);findLatestByContentDocumentId
global List<ContentVersion> findLatestByContentDocumentId(Set<Id> contentDocumentIds)Retrieves the latest ContentVersion records for the specified ContentDocument IDs.
Parameters
| Parameter | Type | Description |
|---|---|---|
contentDocumentIds | Set | Set of Content Document IDs for which to retrieve the latest content versions. |
Returns ContentVersion — A list of the latest ContentVersion records corresponding to each provided ContentDocument ID.
Example
List<ContentVersion> result = instance.findLatestByContentDocumentId(recordIds);getAll
global List<ContentVersion> getAll()Retrieves all ContentVersion records in the system. This method only returns data when called during a test context.
Returns ContentVersion — A list of all ContentVersion records if in a test context; otherwise, returns an empty list.
Example
List<ContentVersion> allVersions = new SEL_ContentVersion().getAll();getFields
global override List<SObjectField> getFields()Returns the default fields for ContentVersion queries.
Returns SObjectField — List of SObjectField tokens to include in queries.
Example
List<SObjectField> result = instance.getFields();Constructors
| Constructor | Description |
|---|---|
| global SEL_ContentVersion() | Reads ContentVersion records, the versions of files stored in the org. |
SEL_ContentVersion()
global SEL_ContentVersion()Reads ContentVersion records, the versions of files stored in the org. Every query skips the running user's object and field permission checks (system mode). Record sharing follows the class that calls the selector. Creating the selector runs no query.
Example
SEL_ContentVersion instance = new SEL_ContentVersion();