Create Attachment
The CloudFiles: Create Attachment flow action allows you to link a file or folder from an external cloud storage service (e.g., Google Drive, SharePoint, Dropbox) to a Salesforce record. Once linked, these files or folders appear in the CloudFiles Widget on the Salesforce record's page, providing seamless integration between Salesforce and cloud storage.
The image below illustrates a sample flow using the Create Attachment action to link a resource (file or folder) to a Salesforce record. Detailed explanations of input parameters and usage are provided in the following sections.
The Create Attachment action simplifies the process of linking external storage resources with Salesforce records, ensuring quick access through the CloudFiles widget.
Imagine you want to set up an automation that creates a folder in external storage for every new Salesforce Account record. To make this folder accessible from the Account record page, you can:
- Use the Create Attachment action to link the newly created folder to the Salesforce Account record.
This ensures the folder is automatically connected and accessible in the CloudFiles widget on the Account record page, eliminating the need to manually connect a folder to the Record.
Below is an example of an attached folder -
When adding the CloudFiles: Create Attachment action in Flow Builder, configure the following input parameters:
- Description: The unique ID of the resource (file or folder) to be attached.
- How to Get It: Use the output of a previous flow actions like Create Folder or Get Resource Details to retrieve the resource ID. For example, {!Outputs from Create Folder} > Resource ID.
- Description: Indicates whether the resource is a file or a folder.
- Valid Values: file or folder
- Description: The external storage service where the resource is located.
- Valid Values: sharepoint, google, azure ,onedrive, dropbox, box, or cloudfiles (AWS S3).
- Description: The drive ID for Google Drive or SharePoint where the resource resides.
- Required For: Google Drive, SharePoint.
- How to Get It:
- Use the output of a previous flow actions like Create Folder or Get Resource Details to retrieve the Drive ID.
- OR Retrieve this from the Content Library Tab in Salesforce using the "View Metadata" button.
- Description: The ID of the Salesforce record to which the resource will be attached.
- Example: Use {!$Record.Id} in a record-triggered flow or specify a dynamic value, such as {!Triggering Account} > Account ID.
How to Get Metadata Details ?
Some of these Parameters like DriveID can be obtained from within Salesforce CloudFiles App by navigating to the parent folder in the Content Library Tab and clicking the "View Metadata" button as shown in image below.
Follow the steps below to retrieve these IDs -
- Click on App Launcher on top left. Search for the CloudFiles App.
- In the CloudFiles App, select the Content Library Tab.
- Go to your cloud storage. You may need to login if you haven't done so before.
- Go to the target folder where you would like to place the created folders in.
- A dialog box opens up which shows all the IDs. Copy the ID from here.
These steps are shown in the GIF below -
The Apex action generates a custom type called Attachment as its output. While it does not explicitly list output parameters, you can retrieve the following information for use in subsequent steps:
- Attachment ID
- The CloudFiles unique ID of the created attachment.
- Resource ID: External ID of the resource.
- Name: Name of the attached resource.
- Path: The path of the resource in external storage.
- Type: Type of the resource ("file" or "folder").
- Library: External storage service used.
- Drive ID: Relevant for Google Drive or SharePoint.
These values can be used for further operations or stored for reference.
The image below shows the output of the create attachment apex action.
In the gif below, we have shown how we create the attachment and attach the created folder to the Salesforce account record.