3

I am unable to delete the contentDocument(Files) owned by some other user even as an admin. I am trying it through apex. When I write a SOQL query it only retrieves records that are owned by me, if some more records are there with owner as someone else then it will not appear in query results.

SOQL Query that I am trying is SELECT ID, OwnerId, title, ParentId from contentDocument USING Scope Everything

1
  • 1
    Thanks for the responses. I understood the basic issue with the contentDocument object permissions. You can delete the ContentDocument only if you are the owner of it or it is shared with you by someone. Otherwise there is no direct way of deleting the ContentDocument records owned by another user. Commented Feb 1, 2019 at 11:08

2 Answers 2

5

With Spring 19' update there is a new setting in the "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 https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentversion.htm.

1
  • 2
    Yes we had created permission set with the same permission and now it is working fine. Thank you for the solution. Commented Jul 20, 2020 at 14:37
2

You must be clear of these things:-

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 Salesforce Files they own, posted on their profile, posted on groups they can see, and shared directly with them (API version 21.0
    and later).

And, For deleting the ContentDocument:-

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.

Refer here :- ContentDocument

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .