Newer Version Available
ContentVersion
Represents a specific version of a document in Salesforce CRM Content or file in Chatter. The maximum number of versions that can be published in a 24-hour period is 36,000. This object is available in versions 17.0 and later for Salesforce CRM Content documents. This object is available in versions 20.0 and later for Chatter files.
Supported Calls
create(), describeLayout(), describeSObjects(), query(), retrieve(), search(), update(), upsert()
Special Access Rules
- 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.
- All users with a content feature license can create versions in their personal library.
-
Users (including users with
the “View All Data” permission) can only query files
they have access to, including:
- All Salesforce CRM Content files in libraries they're a member of and in their personal library, regardless of library permissions (API version 17.0 and later).
- All Chatter files they own, posted on their profile, posted on groups they can see, and shared directly with them (API version 21.0 and later).
- 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”
- 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.
Fields
| Field | Details |
|---|---|
| Checksum |
|
| ContentDocumentId |
|
| ContentLocation |
|
| ContentModifiedById |
|
| ContentModifiedDate |
|
| ContentSize |
|
| ContentUrl |
|
| Description |
|
| Division |
|
| ExternalDataSourceId |
|
| ExternalDocumentInfo1 |
|
| ExternalDocumentInfo2 |
|
| FeaturedContentBoost |
|
| FeaturedContentDate |
|
| FileExtension |
|
| FileType |
|
| FirstPublishLocationId |
|
| IsEncrypted |
|
| IsLatest |
|
| IsMajorVersion |
|
| Language |
|
| NegativeRatingCount |
|
| NetworkId |
|
| Origin |
|
| OwnerId |
|
| PathOnClient |
|
| PositiveRatingCount |
|
| PublishStatus |
|
| RatingCount |
|
| ReasonForChange |
|
| RecordTypeId |
|
| SharingOption |
|
| TagCsv |
|
| Text Preview |
|
| 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 Chatter 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 file in Chatter.
- Use this object to create, query, retrieve, search, edit, and update a specific version of a Chatter file. Use the ContentDocument object to retrieve, query, update, and delete the latest version of a file in Chatter.
- If Chatter isn't enabled, Chatter files aren't included in query results.
- 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 Chatter 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 must be less than 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%. You must account for the base64 conversion increase so that the file you plan to upload is less than 50 MB.
- 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 36,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.