Skip to main content

Hi, how can Skuid features be used to display the file attachments in Salesforce. We are exploring how Skuid can be used for KYC process where we can display the customer documents in a Skuid Page and the document checker can put his comments and decision on the Skuid page itself. The Skuid KYC page should pick up all SF attachments for that customer one by one. Thanks

We’ve done something similar for other customers. You can create a queue of all the attachments. This presents a list that users can work through one at a time.


Activating an entry in the queue will load the detailed attachment. If customer documents are images you can display them in a template component. Make sure the template is connected to the model that is loaded with attachment details. The contents of the template will display the file using html image tags. Something like servlet.FileDownload?file=%7B%7BAttachmentId%7D%7D . Replace “AttachmentId” with the field that is the ID of the attachment.


you can add height and width attributes to that img tag.


If your files are PDF, you can use the native PDF viewer in your browser.


Hopefully this gives you some direction.


I found a way to both preview and download my files attached to records. I pieced this together courtesy of StackExchange and Salesforce documentation:
https://salesforce.stackexchange.com/questions/16016/preview-chatter-file-in-visualforce
https://developer.salesforce.com/blogs/engineering/2014/04/building-content-rich-visualforce-pages-with-salesforce-crm-content.html

Note, this solution applies to Files in the ContentDocument object rather than the Attachment object, which we don’t use at my org.

My model uses ContentDocumentLink, with conditions:

  1. LinkEntityId from source object of the record the File is attached to.

  2. ContentDocument.LatestPublishedVersion.IsLatest = true

I have a table that uses this model to get all Files for the record in the current page.

Row actions on my table:

  1. Preview is a Pop-up action that contains an Image component that uses my File model, with Source URL set to: /sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId={{ContentDocument.LatestPublishedVersion.Id}}


  2. Download is a Redirect to URL action, the URL is: /sfc/servlet.shepherd/version/download/{{ContentDocument.LatestPublishedVersion.Id}}

For Preview, there are three options for the thumbnail dimension URL parameter:
  1. THUMB120BY90

  2. THUMB240BY180

  3. THUMB720BY480

The biggest of these works best for documents in Word or PDF format, but it won’t always look great with images. Looking through fields in objects like ContentDocument and LatestPublishedVersion, I don’t see a field for file metadata, and I don’t know of a way to query file metadata that would give you dimensions. But if there’s a way to query file dimensions you could render your Preview buttons to choose the best THUMB dimensions.


Thanks for the tip here Tim!  Exactly what I was trying to accomplish as well!


So helpful, thank you!


Just wanted to share a quick finding here in case anyone is struggling with getting a clear image preview. I was having trouble using these three:


  1. THUMB120BY90

  2. THUMB240BY180

  3. THUMB720BY480

None of these options seemed to bring back a clear picture. Found this thread online that mentions rendering as SVGZ: https://salesforce.stackexchange.com/questions/203030/content-document-download-url-params

And it works great!


Nicholas,

The Stack Exchange posting you linked also had a cool tip on how to download a list of files into a zip file.  I created demo page of how to do this.  I’m going to create a separate posting for this.

Thanks!

Bill


Didn’t even notice, but sweet! Thanks Bill!


Hi ,

While trying the SVGZ or even the THUMB… , only first page id being displayed of the pdf file(even when the pdf contains 2/3 or more pages) . Can you please help in this case.


Not very familiar with ContentDocumentLink, can anyone give an example of what the condition value is for number 1: LinkEntityId from source object of the record the File is attached to?


@Rob D


Take a look at this posting.  It has a sample page that you can install to see how the model condition is set.


https://community.skuid.com/t/download-selected-salesforce-files-as-zip-file

Thanks,

Bill


Also Rob D - take a look at the Sample Pages Github repo.  We’ve published an exploration of the Content Document structure there.  https://github.com/skuid/SamplePages/tree/master/Salesforce_Advanced/Content_Document

You can download the XML from that repo and create a new page in your org with it.  Then explore the model relationships and the way components are used to interact with the content document objects. 


Thanks! These are great resources. One challenge discovered (related to Salesforce, not Skuid) is that it appears standard Customer Community license users cannot view these tables based on their permissions related to content (looks like maybe Customer Community Plus can?).

Strangely, I think they can still upload the files via Skuid (just not interact with them once uploaded). Anyone else hit this wall or find a workaround beyond upgrading licensing with Salesforce?

For our use case, we are have file attachments to records created for an online Skuid Form based member application.