Newer Version Available
ContentDocument
Represents a document that has been uploaded to a library in
Salesforce CRM Content or Salesforce Files. This object is available in versions 17.0
and later for Salesforce CRM Content. This object
is available in API version 21.0 and later for Salesforce Files.
The maximum number of documents that can be published is 30,000,000.
Archived files count toward this limit and toward storage usage limits.
- Contact Manager, Group, Professional, Enterprise, Unlimited, and Performance Edition customers can publish a maximum of 200,000 new versions per 24-hour period.
- Developer Edition and trial users can publish a maximum of 2,500 new versions per 24-hour period.
Supported Calls
delete(), describeLayout()describeSObjects(), query(), retrieve(), search(), undelete(), update()
Special Access Rules
-
By default, users (including users with the
“View All Data” permission) can only query files they have
access to, including:
- Salesforce Files in their personal library and in libraries they're a member of, regardless of library permissions (API version 17.0 and later).
- Salesforce Files they own, shared directly with them, posted on their profile, or posted on groups they can see (API version 21.0 and later).
Enable the Query All Files permission to let your View All Data users bypass the restrictions on querying files.- Query All Files returns all files, including files in non-member libraries and files in unlisted groups.
- Users can’t edit, upload new versions, or delete files they don’t have access to.
- View All Data permission is required to enable Query All Files.
- Customer and Partner Portal users must have the “View Content in Portal” permission to query content in libraries where they have access.
- A Salesforce CRM Content document can be deleted if any of the following are true:
- The document is published into a personal library or is in the user's upload queue.
- The document is published into a public library, the user is a member of that library with the “Add Content” library privilege enabled, and the user trying to delete the document is the owner.
- The document is published into a public library that has the “Delete Content” or “Manage Library” permission enabled, and the user trying to delete the document is not the owner.
For API version 25.0 and later, you can change ownership of Salesforce Files and
Salesforce CRM Content documents.
- The following must be true to change ownership of a Salesforce CRM Content document:
- The Salesforce CRM Content app must be enabled.
- The user who is becoming the owner of the document must have a Salesforce CRM Content feature license.
- A user can change ownership of a Salesforce CRM Content document or Salesforce file if any
of the following are true:
- The user is the current owner, or has either the “Modify All Data” or "Manage Salesforce CRM Content” permission enabled.
- The user has the “Manage Library” permission enabled for the library containing the document.
Fields
Usage
- Use this object to retrieve, query, update, and delete the latest version of a document in a library or a Salesforce file. Use the ContentVersion object to create, query, retrieve, search, edit, and update a specific version of a Salesforce CRM Content document or Salesforce file.
- The query() call doesn’t return archived documents. The queryAll() call returns archived documents.
- You can’t add new versions of archived documents.
-
To
query a file that is accessible only through a record share, you must
specify the content ID of the file. When SOQL querying
the ContentVersion object, either the ContentVersionId
or the ContentDocumentId must be compounded by an AND
operator.
For example,
1SELECT FileExtension, Title FROM ContentVersion 2WHERE (ContentDocumentId = '<ContentDocumentId>' or Id='<ContentVersionId>') and IsLatest=true1SELECT Id, VersionData, FileExtension, Title FROM ContentVersion 2WHERE ContentDocumentId='<ContentDocumentId>' AND FirstPublishLocationId = '<FirstPublishLocationId>'
- To create a document, create version via the ContentVersion object without setting the ContentDocumentId. This process automatically creates a parent document record. When adding a new version of the document, you must specify an existing ContentDocumentId which initiates the revision process for the document. When the latest version is published, the title, owner, and publish status fields are updated in the document.
- When you delete a document, all versions of that document are deleted, including ratings, comments, and tags.
- If you query versions in the API, versions with a PublishStatus of Upload Interrupted are not returned.
- A document record is a container for multiple version records. You create a version to add a document to the system. The new version contains the actual file data which allows the document to have multiple versions. The version stores the body of the uploaded document.
- Assign topics to ContentDocument using TopicAssignment in API version 37.0 or later.
Associated Objects
This object has the following associated objects. Unless noted, associated objects are available in the same API version as this object.
- ContentDocumentFeed (API version 20.0)
- Feed tracking is available for the object.
- ContentDocumentHistory
- History is available for tracked fields of the object.