Sorry if this seems easy, but I am new to Salesforce…
What I did so far is:
- Query files using apex
- Do operations according to VersionData of queried files
Everything works as expected. However, when a different user triggers the operation to fetch the files, he can not access my library. How can I create the files so that all users can access them or how can I access higher level users library?
Thanks in advance!
File creation:
ContentVersion contentVersion_1 = new ContentVersion(
Title = 'some title',
PathOnClient = 'some title'+'.txt',
VersionData = Blob.valueOf('some content to access later on'),
IsMajorVersion = false /*so that can be updated later on*/
);
insert contentVersion_1;
File Querying:
List<ContentVersion> jsonFiles=[select Title, VersionData from ContentVersion where Title='some title'];
Best Answer
I've seen this issue before. I solved it by changing the FirstPublishLocationId (described here) to a public folder:
If this is truly to be a public folder you can probably create a new public folder using this documentation. If not you can also modify the folder to be accessible to a sub set of users by user id, or by profile.