Obtaining all ContentDocument records using SOQL

  • According to the Salesforce documentation on ContentDocument

    Users (including users with the “View All Data” permission) can only query files they have access

    I find this very strange. Why would a System Administrator not be allowed to see all ContentDocument records within Salesforce?

    Is there a way to circumvent this limitation?

    EDIT: The weirdest thing about all this is that the Admin user can see the ContentDocument in the Salesforce web interface.. but they can't be obtained through the API. That makes little sense. I'd expect the API to show as much or more data than the web interface, not the opposite.

    "Why would a System Administrator not be allowed to see all ContentDocument records within Salesforce?" : Are you able to change the settings for System Admins and make it disable for them?

    What do you mean? My main objective is not to hide the ContentDocuments that do not belong to the administrator. I want to see all the ContentDocument records through the Salesforce API. Since the administrator can see them within the web interface, I'd expect him to be able to see them through the API.

    This question was asked several years ago and the USING SCOPE does not solve ALL permutations. The question is how do you SOQL to get all ContentDocument records without doing work arounds like querying all the ContentDocumentLink records.

    @CoryCowgill What if you just add the user to all libraries? Then they have access.

  • Denis S.

    Denis S. Correct answer

    2 years ago

    Just found out today that with the Spring 19' update there is a new setting in the "Setup -> Permission Sets -> (choose an existing or create a new one) -> App Permission -> Content -> Query All Files: Allows View All Data users to SOQL query all files in the org".

    This is not enabled by default for the admin user but you can at least enable it in a Profile/Permissions Set.

    Also, now documented in the API Documentation.

    Have fun!

    Full path: Setup->Permission Sets -> (choose an existing or create a new one) ->App Permission -> Under the 'Content' section you will see 'Query All Files'.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM