Platform Events
All Event Types

Salesforce File Attached

Overview

This event is published when a file is uploaded to Salesforce (as a ContentDocument)and Linked to a Salesforce Object Record (as a ContentDocumentLink), through "Files" or "Notes & Attachments" section.

This event is not published when a file is uploaded into Salesforce as the old standard Attachment format.

This event should not be confused with File Uploaded, which is published when a file is uploaded to external storage through the CloudFiles widget.

How To Use This Event ?

To use CloudFiles Platform Events, you must first setup your platform event triggered flow as shown in the CloudFiles Event Handler Flow Template. This article will introduce you to the concepts of the event type in the CloudFiles Event Object as well as event details that are returned by the Get Event Details flow action.

Once you are familiar with these, you will understand how to interpret & use these as illustrated in the sections below.

Document image


Event Type For Decision Filter

Please use salesforce-file-attached as the type filter when selecting this event in the decision element in flow builder.

Output Fields From Get Event Details

The corresponding Get Event Details flow action returns the Salesforce Files Details sub-type with useful information including files, content document Ids, parent Id and parent type. Refer to the image below for a list of outputs and descriptions of the parameters returned in this sub-type.

Document image

  1. Parent Id - Id of the Salesforce record where the file is uploaded
  2. Parent Type - Type of the Salesforce record where the file is uploaded. Example - Account
  3. ContentDocumentIds - A list of ContentDocumentId. When multiple files are uploaded together, only one instance of this event is published holding all the uploaded file ids as ContentDocumentIds
  4. Files - A list of Salesforce File object

Use Cases

Here are a few use-cases for this platform event.

  1. Copy the salesforce file auto-attached by external tools such as document generation apps to external storage folders & sub-folders as soon as they are uploaded to save on Salesforce storage and provide access to entire team.
  2. If people are manually uploading files and sometimes mistakenly upload them into the Salesforce Files Component, copy them external storage so that team members not in Salesforce also have access.
  3. Transfer salesforce files to google drive for easier editing using the native google editors. This can also be extended to moving files to SharePoint, OneDrive for easier editing using Microsoft tools such as Word, Excel, Powerpoint etc...