I found this question was answered a year ago: Which Object Stores Content Library Members List. This is essentially what I'm asking. However, the answer provided suggests that there is no way to get the members but yet, it could be possible to get it through ContentWorkspaceDoc.IsOwner. No SOQL or Apex was provided by the answerer.

There's also this question: API Access to Library Members. The asker didn't provide a concrete answer. However, another comment on that page said to try Groups. In my org, I might have users that are not members of Groups.

So, my question is:

Is there Apex or SOQL query that I can use to get the list of Content Library members?

2 Answers 2


Let's say you upload a file under any record or chatter, the file reference is retrieved from ContentDocument object. ContentDocument represents the library in Salesforce CRM Content or Salesforce Files.

Based on the ContentDocumentId, you can retrieve the ShareType and LinkedEntityId from ContentDocumentLink object.

SELECT Id, ShareType, LinkedEntityId, Visibility
FROM ContentDocumentLink 
WHERE ContentDocumentId = '069q00000001jv0'

Here LinkedEntityId will return list of users.




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 premission. The user can explicitly view but not edit the shared file.


Collaborator permission. The user can explicitly view and edit the shared file.


Inferred permission. 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.


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.


Specifies whether this file is available to all users, internal users, or shared users. This field is available in API version 26.0 and later. Visibility can have the following values.

AllUsers—The file is available to all users who have permission to see the file.

InternalUsers—The file is available only to internal users who have permission to see the file.

SharedUsers—The file is available to all users who can see the feed to which the file is posted. SharedUsers is used only for files shared with users, and is available only when an org has private org-wide sharing on by default. The SharedUsers value is available in API version 32.0 and later.

For more information, refer ContentDocumentLink

Update based on comments

List<ContentDocumentLink> lstlink = [SELECT Id, ShareType, Visibility, LinkedEntityId FROM ContentDocumentLink 
WHERE ContentDocumentId = '069q00000001jv0'];
    for(ContentDocumentLink cl:lstlink)
        Id objId = cl.LinkedEntityId;
        System.debug(objId + 'Object Name=' + objId.getSObjectType().getDescribe().getName());

In the debug log, I get userids.

  • Thanks for the response! However, I tried this query: List<ContentDocumentLink> stuff = [SELECT Id, ShareType, LinkedEntityId, Visibility FROM ContentDocumentLink WHERE ContentDocumentId = '0690S0000004Nv9']; for( ContentDocumentLink link : stuff ) { System.debug(link.LinkedEntityId); } But all I'm getting is an Id that is pointing to a library, and not a list of users.
    – akcorp2003
    Mar 28, 2017 at 17:23
  • Check my updated ans, I could get the list of user ids where this file has been shared. Now whats your actual question? Mar 28, 2017 at 18:11
  • When I run the query on my document, I get USER_DEBUG [22]|DEBUG|058A0000000UHOoIAOObject Name=ContentWorkspace
    – akcorp2003
    Mar 28, 2017 at 18:45
select MemberId, Member.name from ContentWorkspaceMember  where ContentWorkspaceId ='Salesforce Id of library'

Hope this help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.