Loading

Default visibility for files shared on records

Julkaisupäivä: Oct 13, 2022
Kuvaus
There are different visibility types (AllUsers, InternUsers etc) available for records. When you query the ContentDocumentLink object you will find different Visibility types for different records.

This article explains what affects the different types of visibility and how visibility is assigned by default. 
Ratkaisu


There is no setting for the default visibility of Files shared on records, but having a community changes the visibility options: 

 

  • When there are no communities defined in the org, a  File shared with a record will have a default visibility set to AllUsers.
  • When there is at least one community defined in the org, a File shared with a record will have its visibility set to InternalUsers, by default.
 

Examples:

  1. Attach a file to an Account record in an org with no communities enabled. 

Take that Account Id and run the below query from the workbench. Use the account Id for LinkedEntityId in the WHERE condition. 

SELECT ContentDocumentId, LinkedEntityId, Visibility, ShareType
FROM ContentDocumentLink
WHERE LinkedEntityId='0013D00000QEgMaQAL' 

Output:

ContentDocumentIdLinkedEntityIdVisibilityShareType
0693D0000005ixzQAA0013D00000QEgMaQALAllUsersV
 
  1. Enable Communities and attach a new File to the Account record and run the query again.

Output:

ContentDocumentIdLinkedEntityIdVisibilityShareType
0693D0000005ixzQAA0013D00000QEgMaQALAllUsersV
0693D0000005jGDQAY0013D00000QEgMaQALInternalUsersV

 

Additional Information:

See our ContentDocumentLink documentation for more information about the different visibility types and their definitions.

The default visibility setting can be overridden:

  • In the user interface (UI), when posting a File on the record's Chatter thread, there is an option to select either 'To SF Only' or  'All with access'. 
  • Using the API, when creating the CDL(ContentDocumentLink) between the File and the record, you can use the sample code below:
for(ContentDocumentLink cont : Trigger.new)
{ 
cont.Visibility = 'AllUsers'; 
}



See also
Community User cannot view 'Files' migrated from 'Attachments'
Change the default visibility of Files shared on records using Data Loader
Set File Sharing to Inherit Record Permissions

Knowledge-artikkelin numero

000384243

 
Ladataan
Salesforce Help | Article