5

With Winter 16 release, Salesforce gave the ability to add Files related list to a Custom/Standard object record.

https://docs.releasenotes.salesforce.com/en-us/winter16/release-notes/rn_chatter_files_related_list.htm

Though the documentation says "Files uploaded to a related list are visible only to those who can access the record where they reside, but those with access to the record can share it further (unless the file is frozen).", a community user who has access to the record, cannot see the files uploaded by other internal/external users.

Could any one please provide suggestions how to acheive this?

4

Files uploaded via this related list will only be visible to internal users, and this field is not editable.

One thing you can do is post the file to the record via the Chatter publisher, and specify the visibility in your post. This would give the attached file the same visibility as the post.

Another option is to write a trigger and edit the Visibility field of the ContentDocumentLink that is created when the file is uploaded. Although you might want this to be context aware so that you don't do this whenever any file is created (and also requires some technical knowledge).

| improve this answer | |
2

As citizen conn pointed out you can use a trigger to edit the Visibility to enable community users to view the file. Here's is the exact trigger you'll want so when internal users upload documents, community users can see it:

UpdateContentDocumentLinkVisibilityOnInsert on ContentDocumentLink(before insert)
     { 
       for(ContentDocumentLink l : Trigger.new)
       l.Visibility = 'AllUsers';
     }

Context: With Files enabled, Community users can only see files that were uploaded INTO that community. (i.e., when an internal user with a full SFDC license uploads/creates a file and adds it to a record, the community users can't see it, eventhough you've shared the file with "The Entire Company" AND the community users have access to view the record.)

| improve this answer | |
1

Replace YOUROBJECTAPI with your object api name and it will share only files uploaded on a that object

trigger shareFilesWithCommunityUsers on ContentDocumentLink(before insert){

   Schema.DescribeSObjectResult r = YOUROBJECTAPI.sObjectType.getDescribe();
    String keyPrefix = r.getKeyPrefix();

      for(ContentDocumentLink cdl:trigger.new){
        if((String.valueOf(cdl.LinkedEntityId)).startsWith(keyPrefix)){
          cdl.ShareType = 'I';
          cdl.Visibility = 'AllUsers';
          } 
       }
    }
| improve this answer | |
  • Instead of using cdl.LinedEntityID you might want to use cdl.LinkedEntity.Type – horzel_evh Apr 16 '19 at 9:19

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