salesforce contentdocument

ContentDocument and ContentVersion in Salesforce - An Overview

Salesforce provides a world of standard objects and relationships among them. All the standard objects have their layouts, functionalities and many settings which make them unique. In the Salesforce Platform we can see a bundle of standard objects in a single app and other several objects which play their role in some of the libraries or in other fields.

ContentDocument and ContentVersion are the standard objects for which we rarely get the help to work with it and it is somewhat very much important while working with the content related project or any data file uploading in the org.

dont miss out iconDon't forget to check out: Salesforce Administrator Roles And Responsibilities.

Let’s juggle in the ContentDocument object:

Firstly I would like to say that whenever any file is uploaded in the Salesforce CRM library or while uploading a file for any Record in its record page, we get the ContentDocument object in our org. We can get the ID by the query:

Select ID from contentDocument;

The above query gives the list of IDs of contentDocument uploaded from the user end.

ContentDocument has its child standard object that is contentVersion.

ContentVersion can be found easily from setup then under the object manager list. For getting it’s IDs we can query:

Select ID from contentVersion;

The above query gives the list of IDs of contentVersion for which contentDocument is present as it is related to that. 

ContentDocument represents the document which is uploaded in Salesforce Files or in the Salesforce CRM libraries whereas ContentVersion contains the specific version of that document. 

As we are aware that Salesforce integration is the prominent part and to establish the relationship among the documents shared between the users in one org to the integrated different org. To accomplish this, contentDocument Link comes into consideration.

From this, we get to know that contentDocument Link contains a link which is used to share the files with the users, groups and other parties.

dont miss out iconCheck out another amazing article by Anjali here: Salesforce Best practices to keep in mind.

To get the link:

Select LinkedEntityId from ContentDocumentLink where ContentDocumentID=’//*id*//’ ;

The above query will provide the two links respective with one contentDocument. One of the links is the owner or the user which has the document and the second link is for the data file which shows where it is  present in the org.

Usage of contentVersion:

  1. This object is used to query, create, search, retrieve, edit the version of the content uploaded in the Salesforce CRM or in the data files.
  2. Not all fields can be set in Salesforce files.
  3. For querying a file that is shared with a record only, then its ContentID must be specified.
  4. Versions can’t be archived.
  5. Deletion of version via API is not possible.
  6. Maximum file size of 50MB can be uploaded via SOAP API.
  7. While querying on versions of the document, all the versions of that corresponding document is returned in the output list.
  8. Record type versions can be updated, on the API version 32.0 or later.

Usage of contentDocument:

  1. This object can be used to update, retrieve, query the version of the document but not on the content pack that is present in the Salesforce library or files.
  2. To get the archived document, use queryAll() call.
  3. To get a non-archived document, use query() call.
  4. New versions of archived documents cannot be added.
  5. Operations like delete, edit, update cannot be done on content packs via API.
  6. Whenever a document is deleted, all of its versions and ratings are deleted.

Related Articles

Responses