Possible to preview attached files?

  • 5
  • Idea
  • Updated 5 years ago
  • Planned
I read through the tutorial Using The File Component to Attach Files to a Record (http://help.skuidify.com/s/tutorials/...).

It all makes sense and it works fine to upload a document. But for viewing, it would be ideal to be able to make use of the way Salesforce previews Chatter Files, as it's visually more appealing than opening an attached document in a separate browser tab/window.

But am I right in thinking that that's not possible because you're storing the file in the old Attachment object, rather than the Chatter Files data structure? And is that the longer term plan?
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,788 Points 5k badge 2x thumb

Posted 6 years ago

  • 5
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,788 Points 5k badge 2x thumb
File previewing would certainly be nice to have. I'm pretty sure the way Salesforce does it isn't available in Visualforce components, so I guess Skuid will need to do something from scratch. Salesforce is Flash-based anyway, which isn't ideal. Javascript based would be preferable.

Re the data structure, I'm pretty certain that the Chatter Files data structure is very much strategic for Salesforce, whereas the Attachment object isn't. If Skuid uses the Chatter File structure, that would give us more confidence that as Salesforce continues to improve its Chatter UI (perhaps with better Visualforce components) we'll be able to leverage those improvements within Skuid.
Photo of Anna Wiersema

Anna Wiersema, Alum

  • 10,920 Points 10k badge 2x thumb
That sounds really great... we are definitely trying to make sure we're at the front of all Salesforce UI developments (especially re: Chatter. :)
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,788 Points 5k badge 2x thumb
Thought I'd fill you in on how I've addressed this for now.

I want to use the Chatter Files data structure for the sake of future proofing, and I want users to be able to preview files. So my Account View page (built from your Account View Starter Page) has a new model called ContentDocuments, which is based on the ContentDocumentLink object. This returns the Chatter Files associated with the Account. I then created a template field in a table on that model to have a link to the file preview page, which I open in a new browser tab. It's not perfect, but it's quite usable for now.

Users upload files through the Feed tab, just as in normal Chatter. Again, not perfect having the file list and the upload button in different tabs, but the benefits outweigh this, if only just.

I'll share the code when I get a moment.
Photo of Kaede Holland

Kaede Holland

  • 3,166 Points 3k badge 2x thumb
Thank you so much for sharing this, Glenn! Really helped me out.
Photo of Chris Hilger

Chris Hilger

  • 130 Points 100 badge 2x thumb
Can you please post the code? I am getting an error 2. An error occurred while attempting to perform the following SOQL query: SELECT Id,LinkedEntity.Name,ContentDocumentId FROM ContentDocumentLink LIMIT 101 Error:Implementation restriction: ContentDocumentLink requires a filter by a single Id, ContentDocumentId or LinkedEntityId using the equals operator
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,788 Points 5k badge 2x thumb
Hi Chris ... the page that I have this in is huge. I could post it, but it would be challenging to interrogate. That error you report is correct and as expected. The Chatter objects have certain implementation restrictions and to use ContentDocumentLink, you have to pass in an Id to filter it. My page is an account view page, so I filter mine on LinkedEntityId equals my account Id. Hope that makes sense.