Recently I was talking with Michelle Hansen who had the use case that she’d like to run a Flow when a file is shared to a record.

Naturally, she explored options with Process Builder and saw that the ContentDocumentLink object (which links a file to a record) wasn’t supported. Womp womp. ☹️

Process Builder does not support Content objects

Previously I’ve blogged about workarounds to the limitation that ContentDocumentLink, ContentDocument, and ContentVersion objects are not supported in Process Builder to monitor for record changes. Please vote for Terence Chiu’s idea to encourage Salesforce to add this support.

Not to be deterred, Michelle and I collaborated to develop an Apex trigger that could know when a file was being shared to a record and then call an autolaunched flow where the business logic could be implemented declaratively.

With the trigger deployed and a flow for it to call, admins can now implement their own business logic declaratively to handle when files are being shared to records. Hooray!

Autolaunched flow to handle files shared to records

The project comes with a simple flow that just posts to Chatter to show that the integration is working. Once you deploy this to your org, you can customize the provided flow’s actions to meet your needs.

Demo showing Chatter post after file shared to record

Learn more about this solution and how to get it deployed to your org at https://github.com/douglascayers/sfdx-handle-file-shared-to-record-flow.

Resources