4

We have this record in Salesforce with Files attached to it. enter image description here

When I execute this query as an administrator via the developer console, it gives me results:

[SELECT ContentDocumentId, ContentDocument.Title,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =:contractId]

When I run the same query as a customer portal user it returns zero results.

Knowing that LinkedEntityId matches the id of a record that the portal user has access to, as shown in the image enter image description here

Does anyone know why I don't get any results from this query as a community user or how I can get the public URL for this document via apex?

2
  • 1
    can you check if portal user has access to the Contract record? Jan 16, 2018 at 14:40
  • Does it show up if you do it as a child subquery instead? SELECT Id, (SELECT ContentDocumentId, ContentDocument.Title,LinkedEntityId FROM ContentDocumentLinks) FROM Contract WHERE Id =:contractId
    – Charles T
    Jan 16, 2018 at 15:40

1 Answer 1

1

The Visibility field of ContentDocumentLink needs to be “AllUsers”

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm

One way to do this is make a Chatter post, attach the existing Salesforce file to the post, and set the post’s audience to “All with access” then submit the post. This will cause the file to be visible to all users with access to the record the file is shared with.

You must log in to answer this question.

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