1

I saw that since Summer 20 changes to the rights of the Force.com Site have taken place (https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_networks_guest_user.htm)

Currently I am creating a file linked to an object record after validating a VisualForce form on a public URL (Force.com Site Guest User) Here is the code for creating the file

/* */
// insert candidate ;
/* */
private void addAttachment(Candidate__c candidate, Attachment file) {
    ContentVersion[] contentVersions = new List<ContentVersion>();
    ContentVersion contentVersion = createContentVers(file.Name, file.Body);
    contentVersions.add(contentVersion);
    insert contentVersions;

    contentVersions = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id IN :contentVersions];
    
    ContentDocumentLink contentDocumentLink = new ContentDocumentLink();
    contentDocumentLink.ContentDocumentId = contentDocumentId;
    contentDocumentLink.LinkedEntityId = candidate.Id;
    contentDocumentLink.ShareType = 'I';
    contentDocumentLink.Visibility = 'AllUsers';
    insert contentDocumentLink;

I tested by putting the read / create rights on the Candidate__c object and its fields in the site profile (Public access settings) -> The preview of the file linked to the Candidate__c record created by the form is not displayed

On the other hand when I put in "Sharing Settings" the sharing in reading with the option "Guest user access, based on criteria" the files created after this modification can be previewed but not those created before

Do you have an explanation? (I saw in the documentation that the sharing rules are set to private for the Guest User but yet the profile of the Guest is indeed in Read / Create for the Candidate__c object) (The creation of the record with all the fields filled in is done correctly without adding a sharing rule, only the file is not previewed)

In addition, would it be possible that the files created before setting the sharing rule with the option "Guest user access, based on criteria" can be previewed?

Thanks for your help,

PS: File preview was previously functional

1
  • I also have same issue. Dec 6 '20 at 17:39

Your Answer

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

Browse other questions tagged or ask your own question.