3

Background

(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.

Need

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.

Ask

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

2 Answers 2

4

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.

6
  • @KrisConcalves, I'm not sure this is correct. I queried a file before and after setting the "Customer Access" toggle to True, and both times it listed AllUsers = I, InternalUsers = V for the Visibility/ShareType fields.
    – Jwok
    Commented Feb 7, 2020 at 21:40
  • I'm not sure I'm following what you said the results were as it was easy for me to replicate it in my own org. There could be many ContentDocumentLink records on a given ContentDocument so I'd make sure you're looking at the right one that's associated to a record, hence my query containing LinkedEntityId. Commented Feb 7, 2020 at 22:27
  • Sure thing - when I query the ContentDocumentLink for a test file, I get two records that are automatically generated. The first has Visibility: AllUsers and ShareType: I, the second InternalUsers and V respectively. Neither of these values change when I toggle "Customer Access", nor is a new ContendDocumentLink created, so I don't see any connection between ContentDocumentLink and the "Customer Access" status.
    – Jwok
    Commented Feb 7, 2020 at 23:19
  • How are you testing? I'm testing as an internal user uploading a brand new file in the file related list of a record (in this case, an account). I suggest using the query I provided to only return one ContentDocumentLink record (the one for the file and object that has the customer access toggle) to help debugging as well. It sounds like it's set to AllUsers already when it's uploaded (is the customer access flag also enabled on creation?) which shouldn't be the case. Commented Feb 7, 2020 at 23:46
  • Ah, no you are right - I see now that the AllUsers link switches from I to V when I manually toggle the "Customer Access" option. This answers the question, so I'm marking this as accepted, but unfortunately it doesn't resolve my business need as it seems that ContentDocumentLink records can't be updated via apex or other API called : (
    – Jwok
    Commented Feb 8, 2020 at 0:20
0

but unfortunately it doesn't resolve my business need as it seems that ContentDocumentLink records can't be updated via apex or other API called

You can update ContentDocumentLink records via API. Just take a look at the developer help, section supported calls. ;)

1
  • While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – identigral
    Commented Jun 28, 2021 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .