Copy Resources
The CloudFiles: Copy Resources flow action allows you to copy resources (files or folders) from one location to another within the same connected external storage. This action is useful for automations requiring resource duplication or reorganization, such as creating backup folders, replicating templates, or moving resources to a different location for specific workflows.
The image below demonstrates how the CloudFiles: Copy Resources flow action looks. Detailed explanations of input parameters and usage are provided in the following sections.
The Copy Resources action performs the following tasks:
- Duplicates Resources: It copies files or folders from the source location to the specified destination folder.
- Publishes Events: Instead of returning outputs immediately, the action publishes a Resource Cloned event for each resource copied, enabling downstream automations.
Scenario: Automate the creation of account folders with predefined subfolder structures.
- Use the Create Folder action to create an account folder.
- Retrieve the contents of the template folder using the Get Folder Contents action.
- Loop through the retrieved folder contents and create a text collection of resource IDs.
- Pass this collection to the Copy Resources action to replicate the subfolder structure in the account folder.
The image below provides an overview of such an automation:
The following input parameters are required to configure the Copy Resources action:
- Description: The Drive ID of the destination where the resources will be copied.
- Details: Required for storages with multiple drives (e.g., Google Drive, SharePoint).
- Description: The ID of the folder in the destination location where the resources will be placed.
- Description: The Drive ID of the resources being copied.
- Details: Indicates the current location of the resources to be copied.
How to these Parameters or 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 -
- Description: A text collection containing the Resource IDs of the files or folders to be copied.
- Details: Use a text collection to store multiple resource IDs. For a single resource, convert it to a collection using an assignment element.
Configure File/Folder Ids parameter
The parameter "File/Folder Ids" is a list parameter, which would only accept value of type list. If you're copying a single file/folder, you can convert it to a list using an assignment element.
To do this -
- Insert an "Assignment" element in the flow before the "Copy Resource" action
- In the Variable field, click "New Resource"
- Set up a new resource as shown below -
Please select the Data Type as "Text" and check the box "Allow multiple values(collection)"
4. Click Done, and then configure the assignment element as shown below -
Please note the operator to be used is "Add" and the value is the Id of single file/folder
- Description: The external storage system where the copy operation will take place (e.g., SharePoint, Google Drive, Dropbox).
- Options: Possible values are sharepoint, google (for Google Drive), onedrive, dropbox, box, azure , cloudfiles (for AWS S3).RecordId
Library Specific Limitations
- Azure: The action is not supported.
- Google: The action is supported to copy folder type Resources
Description: The RecordId parameter is used to identify and manage the origin of the created Resource Cloned Event.
Purpose:
- Event Identification: Helps distinguish the source of the event in scenarios where multiple flows use the same action for different objects or use cases.
- Further automations: Enables performing further automations from the triggering event and event deatils.
Key Features:
- Flexible Input: You can input any text string, not just a RecordId.
- Event Output: Whatever you input here will be available in the corresponding Resource Cloned event details as RecordId
How It Works:
- Input the RecordId of the relevant record into this parameter.
- When the event is triggered, the RecordId is included in the event details.
- In the CloudFiles Event Handler Flow Template event-triggered flow, retrieve the RecordId from the event details to filter and process further automations, such as linking the Resource to the record.
This parameter ensures traceability and flexibility in handling files across different flows and use cases.
You can use the RecordId not just to input a RecordId but literally any text string. Whatever, you input into the action shall be output in the corresponding Resource Cloned event
If you need to differentiate the event based on type of Object and also in between two separate scenarios:
- Scenario 1: Input "Scenario1IdentifierTerm_RecordId" as the parameter.
- Scenario 2: Input "Scenario2IdentifierTerm_RecordId" as the parameter.
In the event-triggered flow:
- Fetch the parameter value from the event details.
- Use it to identify the RecordId and differentiate between the two scenarios.
This approach allows you to:
- Retrieve the RecordId for further automation.
- Differentiate between events to handle specific actions based on the scenario.
The CloudFiles: Copy Resources apex action does not return anything as an output in the flow it is used but for every successful resource cloned a Resource Cloned is published. For example, if the action was configured to copy 4 resources, a event is published for each 4 successful copy. This event signals the completion of resource cloning and can be used to trigger platform event flows to perform post-creation actions.
If the action fails due to some reason an error-event event will be triggered and this event can be used in a decision element to diagnose and handle the error.