Newer Version Available

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

ContentDocumentLink

Represents the link between a Salesforce CRM Content document or Chatter file and where it's shared. A file can be shared with other users, Chatter groups, records, and Salesforce CRM Content libraries. This object is available in versions 21.0 and later for Salesforce CRM Content documents and Chatter files.

Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), update()

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.
  • 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).
  • For API version 25.0 and later, creation and deletion of ContentDocumentLink objects with a LinkedEntityId of types User, CollaborationGroup, or Organization are supported via the API.
  • For organizations with the Communities pilot enabled, a document can only be shared with users and groups that are a part of the community the file was created in.

Fields

Field Details
ContentDocumentId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the document.
LinkedEntityId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the linked object. Can include Chatter users, groups, records (any that support Chatter feed tracking including custom objects), and Salesforce CRM Content libraries.
ShareType
Type
picklist
Properties
Create, Filter, Group, Nillable, Restricted picklist, Sort, Update
Description
Required. The permission granted to the user of the shared file in a library. This is determined by the permission the user already has in the library.This field is available in API version 25.0 and later.
Viewer
The user can explicitly view but not edit the shared file.
Collaborator
The user can explicitly view and edit the shared file.
Inferred
The user’s permission is determined by the related record. For shares with a library, this is defined by the permissions the user has in that library.
Visibility
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort
Description
Specifies whether this feed item is available to all users or internal users only. This field is available in API version 26.0 and later, if Salesforce Communities is enabled for your organization.
Visibility can have the following values:
  • AllUsers—The feed item is available to all users who have permission to see the feed item.
  • InternalUsers—The feed item is available to internal users only.
Note the following exceptions for Visibility:
  • For record posts, Visibility is set to InternalUsers for all internal users by default.
  • External users can set Visibility only to AllUsers.
  • On user and group posts, only internal users can set Visibility to InternalUsers.

The visibility of a ContentDocumentLink on a record post is derived from the highest level of visibility of the link on that record.

Usage

Use this object to query the locations where a file is shared or query which files are linked to a particular location. For example, the following query returns a particular document shared with a Chatter group:

1SELECT ContentDocument.title FROM ContentDocumentLink WHERE ContentDocumentId = '069D00000000so2' AND LinkedEntityId = '0D5000000089123'
  • You can't run a query without filters against ContentDocumentLink.
  • You can't filter on ContentDocument fields if you're filtering by ContentDocumentId. You can only filter on ContentDocument fields if you're filtering by LinkedEntityId.
  • You can't filter on the related object fields. For example, you can't filter on the properties of the account to which a file is linked. You can filter on the properties of the file, such as the title field.
A SOQL query must filter on one of Id, ContentDocumentId, or LinkedEntityId.