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!
Yes, all the version will be deleted, check the doc here, ContentDocument
'When you delete a document, all versions of that document are deleted, including ratings, comments, and tags.'
Yeah, there is no standard way to do this.
But you can copy the latest version to a new file, and delete all the old version, like this,
ContentVersion oldCV = [Select Id, VersionData, PathOnClient, ContentUrl, Title, PublishStatus, Origin from ContentVersion Order By CreatedDate Desc Limit 1];
ContentVersion newCV = new ContentVersion();
newCV.Title = oldCV.Title;
newCV.PathOnClient = oldCV.PathOnClient;
newCV.ContentUrl = oldCV.ContentUrl;
newCV.VersionData = oldCV.VersionData;
newCV.Origin = 'H';
insert newCV;
Best Answer
ContentDocument
records are linked to their parents or share locations (of which there may be more than one) usingContentDocumentLink
records. TheId
of the parent record is stored in theLinkedEntityId
field onContentDocumentLink
.I suggest reading through the linked document as you try to design your queries, because there are some unusual restrictions on how you query
ContentDocumentLink
. In particular,and