Salesforce ContentDocument and ContentVersion: tips and tricks

First trick: Get Content Document Id by Content Version Id

SELECT ContentDocumentId from ContentVersion where Id = '068......'

Second trick: Get Content Version Id by Content Document Id

SELECT Id from ContentVersion where ContentDocumentId = '069......'

Third trick: Get Download Number of Document by Version

SELECT Count(Id), ContentVersionId FROM ContentVersionHistory where field='contentVersionDownloaded' and ContentVersion.ContentDocumentId  = '069....'   group by ContentVersionId 

Fourth trick: Get Total Download Number for a Document

SELECT Count(Id) FROM ContentVersionHistory where field='contentVersionDownloaded' and ContentVersion.ContentDocumentId = '069....' group by ContentVersion.ContentDocumentId

Vote for my idea here to make life of Salesforce developer easier if you agree

Advertisements
This entry was posted in apex, content, download, Posts in English, Salesfoce and tagged , , , , , , , . Bookmark the permalink.

2 Responses to Salesforce ContentDocument and ContentVersion: tips and tricks

  1. Sukruti v says:

    I want to validate the file format of the file uploaded on file related list on record detail page and on the object record feed. Which content object to use to achieve this. Contentversion, contentdocument or contentdocumentlink.please help

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s