I'm having some trouble displaying content documents in a table. Error message...

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'm having an issue displaying content documents in a table. There are many content objects. I tried Content Documents which got me just about everything I need except that it doesn't have a Parent Id. I then tried AttachedContentDocument and I get the following Error if I try to put it in a model:

"1. An error occurred while attempting to perform the following SOQL query: SELECT LastModifiedDate,ContentSize,ContentUrl,ContentDocumentId,ContentDocument.Title,CreatedDate,CreatedById,CreatedBy.Name,FileExtension,FileType,LastModifiedById,LastModifiedBy.Name,LinkedEntityId,Title,Id FROM AttachedContentDocument LIMIT 21 Error:entity type AttachedContentDocument does not support query"

I then made a table out of the parent object "Patient" and it lists the attached content documents in the table, but I can't link to the actual file.

I see a tutorial on how to upload files to Chatter/Content and that seems to work well, but I can't get linked content documents to display in a table with live links that take me to the document.

Any ideas would be appreciated.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I am stuck on this. Every road leads to a dead end. If someone could give a quick overview of how one would display content documents in a list and create a URL to the actual document that I could preferably use in a row action to display in a popup window (for browser based files like PDF's) , I would be super grateful!
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Figured it out, for anyone who may stumble across this post. I ended up creating a model based on the ContentDocumentLink object then created a condition that the LinkedEntityID is equal to the parent record id and I pulled fields from the ContentDocumentId object when picking the fields to bring into the model to get the file name, type, size, etc.... Important note, the clickable link for the file name is actually ContentDocumentId. The title field will give you a dead version of the document name.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Glad you got it figured out.  The other way you can get "clickable" content documents is by using the contentVersions child relationship and using href code in your template to build out a link. 

I built a sample page using this method.  Grab the xml at that link and spin up a new page to check it out.    
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Great, Thanks!