Newer Version Available

This content describes an older version of this product. View Latest

ContentDocument

Represents a document that has been uploaded to a library in Salesforce CRM Content or a file in Chatter. This object is available in API versions 17.0 and later for Salesforce CRM Content. The maximum number of documents that can be published is 2,000,000. Archived files count towards this limit and towards storage usage limits..
  • 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.
This object is available in API version 21.0 and later for Chatter files.

Supported Calls

delete(), describeLayout()describeSObjects(), query(), retrieve(), search(), undelete(), update()

Special Access Rules

  • Customer and Partner Portal users must have the “View Content in Portal” permission in order to query content in libraries where they have access.
  • 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).
  • 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 Chatter files and Salesforce CRM Content documents. Note the following:
  • To change ownership of a Chatter file, Chatter must be enabled.
  • 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 Chatter 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.
    • The user who is becoming the owner of the document must be a visible user who is active, but the original owner can be inactive.
    • A document's owner can be changed to a user who doesn’t have access to the library that contains the document. Library administrators may need to give the new owner membership to the library.

    Note

Fields

Field Details
ArchivedById
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The ID of the user who archived the document.

This field is available in API version 24.0 and later.

ArchivedDate
Type
date
Properties
Filter, Group, Nillable, Sort
Description
The date when the document was archived.

This field is available in API version 24.0 and later.

ContentModifiedDate
Type
dateTime
Properties
Filter, Nillable, Sort
Description
Date the document was modified.

ContentModifiedDate updates when, for example, the document is renamed or a new document version is uploaded. When you’re uploading the first version of a document, ContentModifiedDate can be set to the current time or any time in the past.

This field is available in API version 32.0 and later.

ContentSize
Type
int
Properties
Filter, Group, Nillable, Sort
Description

The size of the document in bytes.

This field is available in API version 31.0 and later.

Description
Type
textarea
Properties
Filter, Nillable, Sort
Description

A description of the document.

This field is available in API version 31.0 and later.

Division
Type
picklist
Properties
Defaulted on create, Filter, Group, Restricted picklist, Sort
Description
A logical segment of your organization’s data. Available only if the organization has the Division permission enabled.
FileExtension
Type
string
Properties
Filter, Group, Nillable, Sort
Description

File extension of the document.

This field is available in API version 31.0 and later.

FileType
Type
string
Properties
Filter, Group, Nillable, Sort
Description

Type of document, determined by the file extension.

This field is available in API version 31.0 and later.

IsArchived
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether the document has been archived (true) or not (false).
LastReferencedDate
Type
date
Properties
Filter, Nillable, Sort, Update
Description
The timestamp for when the current user last viewed a record related to this record.
LastViewedDate
Type
date
Properties
Filter, Nillable, Sort, Update
Description
The timestamp for when the current user last viewed this record. If this value is null, this record might only have been referenced (LastReferencedDate) and not viewed.
LatestPublishedVersionId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the latest document version.
OwnerId
Type
reference
Properties
Filter, Group, Sort, Update
Description
ID of the owner of this document.
ParentId
Type
reference
Properties
Filter, Group, Nillable, Sort, Update
Description
ID of the library that owns the document. Created automatically when inserting a ContentVersion via the API for the first time.

This field is available in API version 24.0 and later when Salesforce CRM Content is enabled.

PublishStatus
Type
picklist
Properties
Defaulted on create, Filter, Group, Restricted picklist, Sort
Description
Indicates if and how the document is published. Valid values are:
  • P—The document is published to a public library and is visible to other users. Label is Public.
  • R—The document is published to a personal library and is not visible to other users. Label is Personal Library.
  • U—The document is not published because publishing was interrupted. Label is Upload Interrupted.
SharingOption
Type
picklist
Properties
Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update
Description
Controls whether or not sharing is frozen for a file. Only administrators and file owners with Collaborator access to the file can modify this field. Default is Allowed, which means that new shares are allowed. When set to Restricted, new shares are prevented without affecting existing shares.

This field is available in API versions 35.0 and later.

Title
Type
string
Properties
Filter, Group, Sort
Description

The title of a document.

Usage

  • Use this 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 the ContentVersion object to create, query, retrieve, search, edit, and update a specific version of a Salesforce CRM Content document or Chatter file.
  • The query() call doesn’t return archived documents. The queryAll() call returns archived documents.
  • You can’t add new versions of archived documents.
  • 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.
  • To create a document, create a new version via the ContentVersion object without setting the ContentDocumentId. This 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.
  • You can't create, edit, or delete content packs via the API.

    Content metadata, such as tags, custom fields, and content owners are tracked at the version level rather than at the document level.

    Note

  • 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 new 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.