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.

Since: 1.0

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 findByFirstPublishLocationId(Id firstPublishLocationId)Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId.
global List findByFirstPublishLocationId(Set<Id> firstPublishLocationIds)Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId values.
global List findLatestByContentDocumentId(Set<Id> contentDocumentIds)Retrieves the latest ContentVersion records for the specified ContentDocument IDs.
global List getAll()Retrieves all ContentVersion records in the system.
global override List getFields()Returns the default fields for ContentVersion queries.
global SEL_ContentVersion()Constructs a new SEL_ContentVersion selector instance.

Method Details

SEL_ContentVersion

apex
global SEL_ContentVersion()

Constructs a new SEL_ContentVersion selector instance.

Since: 1.0

Example:

apex
SEL_ContentVersion instance = new SEL_ContentVersion();

findByFirstPublishLocationId

apex
global List<ContentVersion> findByFirstPublishLocationId(Id firstPublishLocationId)

Retrieves the latest ContentVersion records linked to the specified FirstPublishLocationId.

Parameters:

  • 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.

Since: 1.0

Example:

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

findByFirstPublishLocationId

apex
global List<ContentVersion> findByFirstPublishLocationId(Set<Id> firstPublishLocationIds)

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

Parameters:

  • 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.

Since: 1.0

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:

  • 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.

Since: 1.0

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.

Since: 1.0

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.

Since: 1.0

Example:

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