Newer Version Available
ContentVersion
The maximum number of versions that can be published in a 24-hour period is 200,000.
Note: Depending on how files are shared, queries on ContentDocument and ContentVersion without specifying an ID won't return all files a user has access to. For example, if a user only has access to a file because they have access to a record that the file is shared with, the file won't be returned in a query such as "SELECT Id FROM ContentDocument."
Supported Calls
create(), describeLayout(), describeSObjects(), query(), retrieve(), search(), update(), upsert()
Special Access Rules
- All users with a content feature license can create versions in their personal library. Customer and Partner Portal users must also supply the NetworkId of the Experience Cloud site in the request.
- 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.
- All users can update versions in their personal library.
- The owner of a version or document can update the document if they are a member of the library, regardless of library permissions.
- To update a Salesforce CRM Content document, the user must be a member of the
library with one of these library privileges enabled:
- Add Content
- Add Content On Behalf of Others
- Manage Library
- Customer and Partner Portal users must have the View Content in Portal permission to query content in libraries where they have access.
- Customer and Partner Portal users can only publish, version, or edit documents if they have a Salesforce CRM Content feature license.
- FileType is defined by either ContentUrl for links or PathOnClient for documents, but not both.
- In API version 34.0 and later, any file can be shared with libraries, whether the file originated in Chatter or in Salesforce CRM Content.
- In API version 39.0 and later, custom Apex download handlers can be created that can control access to documents. See the Apex Developer Guide for more information.
Fields
| Field | Details |
|---|---|
| Checksum |
|
| ContentBodyId |
|
| ContentDocumentId |
|
| ContentLocation |
|
| ContentModifiedById |
|
| ContentModifiedDate |
|
| ContentSize |
|
| ContentUrl |
|
| Description |
|
| Division |
|
| ExternalDataSourceId |
|
| ExternalDocumentInfo1 |
|
| ExternalDocumentInfo2 |
|
| FeaturedContentBoost |
|
| FeaturedContentDate |
|
| FileExtension |
|
| FileType |
|
| FirstPublishLocationId |
|
| IsAssetEnabled |
|
| IsEncrypted |
|
| IsLatest |
|
| IsMajorVersion |
|
| Language |
|
| NegativeRatingCount |
|
| NetworkId |
|
| Origin |
|
| OwnerId |
|
| PathOnClient |
|
| PositiveRatingCount |
|
| PublishStatus |
|
| RatingCount |
|
| ReasonForChange |
|
| RecordTypeId |
|
| SharingOption |
|
| SharingPrivacy |
|
| TagCsv |
|
| TextPreview |
|
| Title |
|
| VersionData |
|
| VersionNumber |
|
Usage
- Use this object to create, query, retrieve, search, edit, and update a specific version of a Salesforce CRM Content document or Salesforce file. Use the ContentDocument object to retrieve, query, update, and delete the latest version of a document, but not a content pack, in a library or a Salesforce file.
- Use this object to create, query, retrieve, search, edit, and update a specific version of a Salesforce file. Use the ContentDocument object to retrieve, query, update, and delete the latest version of a Salesforce file.
- To query a file that is shared only with a record, you must specify the content ID of the file.
- Not all fields can be set for Salesforce Files.
- You can only update a version if it is the latest version and if it is published.
- You can't archive versions.
- Using API version 32.0 and later, you can update record types on versions.
- You can't delete a version via the API.
- The maximum file size you can upload via the SOAP API is 50 MB. When a document is uploaded or downloaded via the API, it is converted to base64 and stored in VersionData. This conversion increases the document size by approximately 37%. Account for the base64 conversion increase so that the file you plan to upload is less than 50 MB after conversion.
- To download a document via the API, you must export the VersionData of the document. This does not increase the download count.
- When you upload a document from your local drive using the Data Loader, you must specify the actual path in both VersionData and PathOnClient. VersionData identifies the location and extracts the format and PathOnClient identifies the type of document being uploaded.
- SOQL queries on the ContentVersion object return all versions of the document. SOSL searches on the ContentVersion object return only the most recent version of the document.
- If you query versions in the API, versions with a PublishStatus of Upload Interrupted are not returned.
- Documents published into a personal library assume the default record type that is set for the user profile of the person publishing the document (General, if no default is set for the user profile).
- 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.
- Custom validation rules can prevent an update of documents published into a personal library via the API.
Applying Tags to ContentVersion Records
Tags can be applied to ContentVersion records using either Enterprise or Partner API.
To apply tags to a ContentVersion record, set a value in the TagCsv field. For example, setting this field to one,two,three creates and associates three tags to that version.
- The maximum length of the TagCsv field is 2,000 characters.
- The maximum length of an individual tag is 100 characters.
- When tags are applied to a version, the content is indexed automatically and the tags are searchable.
- You can't apply tags to a TagCsv that is published into a personal library.
- You can't apply tags using the ContentDocument object.
- You can't change or delete tag names. You can remove tags from a document, but that doesn't delete the tag.
- Tags are case insensitive. You can't have two tags with the same name even if they use different uppercase and lowercase letters. The case of the original tag is always used.
To delete tags from a ContentVersion record, perform a standard API update, and remove any values from the TagCsv field that you want to delete. For example, if the original TagCsv is one,two,three, perform an API update specifying one,three in the TagCsv field to delete two. To delete all tags from a ContentVersion you perform a standard API update by setting the field to null.
- If you insert the revision and do not set any value in the TagCsv field, any tags applied to the previous version are automatically applied to the new version.
- If you insert the revision and specify a new TagCsv field, no tags transfer over and the tags you specify are applied instead.
When you perform a SOQL query for a ContentVersion record and select the TagCsv field, all the tags associated with that record are returned. The tags in the string are always ordered alphabetically even if they were inserted in a different order. You can't use the TagCsv field as part of a filter in a SOQL query. You can't query all tags in your organization.
Library tagging rules:
- API tagging respects the tagging restrictions that exist on any library that the document is published into. For example, if the library is in restricted tagging mode and only allows tags one,three, you can't save a version with a TagCsv of one,two,three.
- If the library is in guided tagging mode, you can apply tags to the ContentVersion. You can't query the value of guided tags on a library, but you can query the tagging model of a library.
Associated Objects
This object has the following associated objects. Unless noted, they are available in the same API version as this object.
- ContentVersionHistory
- History is available for tracked fields of the object.