0

I am currently creating a public site. This site should display attachments that are attached to a custom object. My plan was to first load the ContentDocumentLink of the object and then the ContentVersion.

As an admin this is no problem. But as a site user I don't get anything back. I have already found out that site users generally have no access to files. BUT: In another org I used exactly the same procedure where it worked. The difference here is that in the working org the site user has the license "Guest User Licence". In the not working org it is only "Guest". Does anyone know a way to change this license? Or an alternative to see images linked to objects?

My idea would be to make a REST call with another user as an ugly solution.

I'm happy for all ideas

0

I found a solution. You need to implement an after_inserttrigger on ContentDocumentLink which inserts a ContentDistribution

   cd.name = 'Test';
   cd.ContentVersionId = cv.Id; //Id of ContentVersion (needs to be retrieved via SOQL)
   cd.PreferencesAllowOriginalDownload = true;
   cd.PreferencesAllowPDFDownload = false;
   cd.PreferencesAllowViewInBrowser = true;
   insert cd;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.