Skip to content

SEL_ContentVersion

Class · Group: Selectors

apex
global inherited sharing class SEL_ContentVersion extends SEL_Base

Extends: SEL_Base

Selector for the ContentVersion object. Provides query methods for retrieving content versions by publishing location, content document, and workspace folders.

Example

apex
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

MethodDescription
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

apex
global List<ContentVersion> findByFirstPublishLocationId(Id firstPublishLocationId)

Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId.

Parameters

ParameterTypeDescription
firstPublishLocationIdIdThe 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

apex
List<ContentVersion> result = instance.findByFirstPublishLocationId(recordId);
apex
global List<ContentVersion> findByFirstPublishLocationId(Set<Id> firstPublishLocationIds)

Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId values.

Parameters

ParameterTypeDescription
firstPublishLocationIdsSetSet of IDs for the locations where the content versions were first published.

Returns ContentVersion — List of ContentVersion records found for the specified locations.

Example

apex
List<ContentVersion> result = instance.findByFirstPublishLocationId(recordIds);

findLatestByContentDocumentId

apex
global List<ContentVersion> findLatestByContentDocumentId(Set<Id> contentDocumentIds)

Retrieves the latest ContentVersion records for the specified ContentDocument IDs.

Parameters

ParameterTypeDescription
contentDocumentIdsSetSet 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

apex
List<ContentVersion> result = instance.findLatestByContentDocumentId(recordIds);

getAll

apex
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

apex
List<ContentVersion> allVersions = new SEL_ContentVersion().getAll();

getFields

apex
global override List<SObjectField> getFields()

Returns the default fields for ContentVersion queries.

Returns SObjectField — List of SObjectField tokens to include in queries.

Example

apex
List<SObjectField> result = instance.getFields();

Constructors

ConstructorDescription
global SEL_ContentVersion()Constructs a new SEL_ContentVersion selector instance.

SEL_ContentVersion()

apex
global SEL_ContentVersion()

Constructs a new SEL_ContentVersion selector instance.

Example

apex
SEL_ContentVersion instance = new SEL_ContentVersion();