Search code examples
salesforcesoql

Using SOQL to move file from Private to Public library


Is there a way I could use the SOQL language to move files from Private to Public library?

I've tried editing the ContentDocument object and changing the ParentId (which obviously doesn't work as ParentId seems to be read-only).

I also attempted to change the PublishStatus, however that seems to be pointless too as there's no way of determining which library will it then belong too. I tried looking into Salesforce documentation, however I can't find a way of connecting the ContentDocument/ContentVersion with a library object (except for the PublishStatus, however as mentioned before that does provide a way to link the Content with Library).

Any help will be greatly appreciated!


Solution

  • Ok, finally got it. For the anyone with similar problem, the solution is (once you know it) very obvious: you can create a link between a library and a content document using ContentWorkspaceDoc, which requires ContentDocumentId (id of the document) and ContentWorkspaceId (id of the library).