Use Case #5: Relate a File to Multiple Records

Associate your new file to more than just the Case. This post is part of the Uploading and Working with Files in Flow mini series.


  • Install/setup flow package
  • Flow: E01_005_RelateAFileToMultipleRecords
  • Standard File Upload flow screen component (included in the flow)
  • Case object – need at least one case record in your org with a related Contact

Video Tutorial (1.5 min)

What’s Happening in the Flow:

  1. This flow is just like the “Rename an Uploaded File” sample flow, but in the loop we aren’t touching ContentDocument at all.
  2. “Create Content Doc Link” query: In the loop, instead of updating a record, we’re creating one: a ContentDocumentLink.
    1. In this sample flow, we want the File to not only show up when looking at the Case, but also when you view the related Contact. We don’t need to upload it twice and suck up valuable file storage – we just need to create another association (a ContentDocumentLink) between the existing ContentDocument and the Contact.
    1. The setting of values:
      1. ContentDocumentId: this is available from the current looped item
      2. LinkedEntityId: this is the Contact record Id, which we can get from the existing getCase query
      3. ShareType: we’ve set this to I (for Inferred), so that access to the file is based on access to the related Contact record (see documentation for other options).
      4. Visibility: we’ve set this to AllUsers, although there are some other options in the documentation.
  3. That’s it! Once you’ve uploaded a file through this sample flow, go to the Contact record and see the same file in both the Case and Contact related lists. Or, even better, just go to the file detail page from one of these locations, and look at the “Shared With” related list to see all the ContentDocumentLinks for the same file.

Please review Some Limits for caveats related to this particular use case.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: