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.

Answer

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!

Attribution
Source : Link , Question Author : GuiSim , Answer Author : Denis S.

Leave a Comment