[SalesForce] Where is a File’s “Customer Access” status located


(This question is a more specified version of ytiq's question File "Customer Access" Permissions)

Salesforce Lightning now requires that a file have the "Customer Access" toggle set to "Enabled" for a Customer Community user to view it (image below for reference, link to documentation here). As far as I have been able to determine, there is no way to set "Customer Access" to default to enabled via Salesforce Setup.

This is creating a problem for our business process, as internal users must now manually toggle this for every file that we share with Customer Community users, greatly amplifying busy-work and room for user error.


I need to determine how to access the "Customer Access" feature/component/field/object, or however it is stored, so that I can build code to set it to automatically share with Customer Community users.


Where is the "Customer Access" element of a File located in Salesforce (what object, field, metadata, etc.).

Image of "Customer Access", with link to salesforce document

Best Answer

It's on the ContentDocumentLink under Visibility as shown here

Visibility can have the following values.

  • 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.
  • SharedUsers—The file is available to all users who can see the feed to which the file is posted. SharedUsers is used only for files
    shared with users, and is available only when an org has private
    org-wide sharing on by default. The SharedUsers value is available in API version 32.0 and later.

When you select CustomerAccess as Enabled, you're essentially setting this Visibility field to AllUsers. You can test this yourself in a sandbox by uploading a file on a given record and querying the ContentDocumentLink with the below query

SELECT Visibility FROM ContentDocumentLink WHERE LinkedEntityId = 'your record' 
AND ContentDocumentId = 'id of the file'

You will see that it's first shared with InternalUsers with the Customer Access disabled and then changes to AllUsers when it is enabled.

Related Topic