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. ☹️
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!
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.
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.