Loading

Default visibility for files shared on records

Date de publication: May 15, 2026
Description

There are different visibility types available for files shared on Salesforce records, including AllUsers and InternalUsers. When you query the ContentDocumentLink object, you will find different Visibility field values for different records.
This article explains what affects the different types of visibility and how visibility is assigned by default when a file is shared on a record.

Résolution


There is no setting for the default visibility of files shared on records, but having a community (Experience Cloud site) changes the visibility options.
Default Visibility Behavior:

  • When there are no communities defined in the org, a file shared with a record has a default visibility of AllUsers.
  • When there is at least one community defined in the org, a file shared with a record has a default visibility of InternalUsers.

Example 1 — Org with no communities:
Attach a file to an Account record in an org with no communities enabled. Query the ContentDocumentLink object using the Account Id in the WHERE condition:
SELECT ContentDocumentId, LinkedEntityId, Visibility, ShareType FROM ContentDocumentLink WHERE LinkedEntityId='[AccountId]'
The result shows Visibility = AllUsers for the new file.

Output:

ContentDocumentIdLinkedEntityIdVisibilityShareType
0693D0000005ixzQAA0013D00000QEgMaQALAllUsersV

 

Example 2 — Org with communities enabled:
Enable Communities and attach a new file to the same Account record. Run the same query again.
The result shows the previously attached file remains Visibility = AllUsers, while the newly attached file shows Visibility = InternalUsers.

Output:

ContentDocumentIdLinkedEntityIdVisibilityShareType
0693D0000005ixzQAA0013D00000QEgMaQALAllUsersV
0693D0000005jGDQAY0013D00000QEgMaQALInternalUsersV

 

Overriding the Default Visibility:
The default visibility can be overridden in two ways:

  1. Using the user interface (UI): When posting a file on the record's Chatter thread, select either 'To SF Only' or 'All with access'.
  2. Using the API: When creating the ContentDocumentLink (CDL) between the file and the record, set the Visibility field to 'AllUsers' in your Apex trigger. For example, loop through the new ContentDocumentLink records in a trigger and set cont.Visibility = 'AllUsers' before insert.
for(ContentDocumentLink cont : Trigger.new)
{ 
cont.Visibility = 'AllUsers'; 
}




Numéro d’article de la base de connaissances

000384243

 
Chargement
Salesforce Help | Article