Apex Aide apexaide

displaying files in flow datatable with clickable link

By Gorav Seth· goravseth.com· ·Intermediate ·Admin ·2 min read
Summary

This solution shows how to display related Salesforce files in a Flow Data Table with clickable links, addressing the challenge of linking Salesforce files that involve multiple objects like ContentDocument, ContentVersion, and ContentDocumentLink. It guides on querying related file links, filtering for latest versions, and creating a custom formula field for clickable hyperlinks in the datatable. The approach helps teams surface files attached to records directly within flows, including in legacy approval process pages, improving usability without heavy coding. It also notes specific Salesforce quirks like using 'ContentDocument.Id' in formulas for hyperlinking.

Takeaways
  • Create a flow input variable 'recordId' to identify the parent record.
  • Query ContentDocumentLink objects to find files related to a record.
  • Filter ContentVersion records to only show the latest version of each file.
  • Add a custom formula field on ContentVersion to generate clickable file links.
  • Use the formula HYPERLINK("/" & CASESAFEID(ContentDocument.Id), Title) for linking.

solved an interesting question on ohana slack asking about how to display the files attached to a related record in a “legacy” approval process page. you can do this using a flow datatable, but there are some tricks required for making a clickable link to the file. salesforce files have 3 objects, and they dont always play nicely a) content document : this is the file preview page when you are looking at a file. IDs start with 069 b) content version : these are the file versions, and IDs start with 068 c) content document link these allow the many to many relationship to connect one content document to multiple records. i dont know what the Ids start with … here is the full flow. here are the details on how to build it to start, you must create an input text variable in your flow named recordId. this will be populated automatically when you add the flow to a record page.

Flow Builder