files not visible to community users when sharing set to "set by record" - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
1,670  Points
Idea has been posted. Give it an upvote or downvote.

files not visible to community users when sharing set to "set by record"

Chatter & Files

Attachments on a record were visible to community user if they had access to the associated record.

We upgraded to files and this is no longer the case even though sharing setting is set to "set by record"

interesting to note is that if you upload a file through chatter and set to "all with access" it is visible to the community user, but there is no equivalent setting on the files sharing setting to grant this initially or even after the fact if uploaded via the Files related list. 

this is a big flaw in the way sharing is handled and a big step backwards for files if the goal is to replace attachments with files

Merge Idea · Flag

Latest Comment from Salesforce

  • Neil Hayek - 1 year ago

    Posting again because I made a mistake with the trigger...

    To understand this behavior, I would suggest viewing reading this knowledge article

    Currently, we provide a way to update the visibility of files through the API, but come Winter '20 (Safe Harbor), we plan to provide a UI way of controlling the visibility.

    For orgs which want the default behavior for all files added to records to be visible to community users who can access the record, they can create a trigger like this in their org:
    trigger SetFileVisibility on ContentDocumentLink (before insert) {
        for (ContentDocumentLink cdl : {
            cdl.visibility = 'AllUsers';

    You can modify the above logic to meet your needs.  For example, if you only wanted this behavior to apply to Files shared to cases, you can create a trigger like this:
    trigger SetFileVisibilityForCases on ContentDocumentLink(before insert) {
         for (ContentDocumentLink cdl : {
              if (cdl.LinkedEntityId.getSObjectType().getDescribe().getName() == 'Case') {
                   cdl.visibility = 'AllUsers';

    For orgs which want to do a mass update of the visibility for existing files, I would suggest using Salesforce's Export feature to export the ContentDocumentLink entity.  This will show how all files are shared inside of the org.  From this list, which will be a .csv file, narrow down to the shares which you want.  For example, if you want to update the visibility for files shared to cases, delete all rows from the csv except for the ones where the LinkedEntityId starts with "500" (the key prefix for cases).  Now that you have these rows, the only columns you need to keep are the Id (for the ContentDocumentLink) and the Visibility column.  Set the visibility as you desire.  You can now use Data Loader to perform an Update on ContentDocumentLink and provide your new .csv file.
  • Upvotes
  • Downvotes



from AppExchange

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.