[SalesForce] Community Users are not able to view files

We have moved all our Notes and Attachment to FIles in lightning, Now none of our Community plus users are able to view the files from their community login. We have added files related list on page layout but it isn't showing up. We have also made sure their profile has access to files. What is more strange to see is, If community users go to files tab and search for any existing file they can find it from the files tab but not on the record. I tried comparing one of the files, and from my login, I can see the file is Shared with a record but the same file from community user login doesn't show any record it is shared with. Anyone else facing this issue? We have more than 700+ community users who are finding files missing from the records which technically isn't true.

Best Answer

this is because you have Visibility as InternalUsers on ContentDocumentLink for each ContentDocument record, that represents lightning Files.

In order, to grant visibility access for Community users, you have to update Visibility to AllUsers for those files that should be visible to community users.

  • AllUsers—The file is available to all users who have permission to see the file.
  • InternalUsers—The file is available only to internal users who have permission to see the file.

Code to update all ContentDocumentLink records. If you don't have to do it for all Files, select only filtered records:

List<ContentDocumentLink> toUpdate = new List<ContentDocumentLink>();
for(ContentDocumentLink link : [
    select Id, Visibility
    from ContentDocumentLink
    where Visibility != 'AllUsers'
    ]){
    link.Visibility = 'AllUsers';
    toUpdate.add(link);
}
update toUpdate;
Related Topic