We'll demonstrate this by building an Archive feature, where users can click an "Archive" button in the CloudFiles widget to move selected files or folders into a designated archive folder in your external storage. This is especially useful during processes like lead conversion, where you want to clean up and store files without deleting them permanently.
What to Expect
By the end of this tutorial, you will be able to:
- Automatically create a main folder with custom sub-folders in your external storage when a Lead is created in Salesforce, and access them directly from the Salesforce record using the CloudFiles widget.
- You will be able to see the Custom Resource Action button you created displayed next to each file and folder.
- By clicking the button, you can move the file or folder to a predefined location (e.g., a predefined archive folder).
The GIF below shows the expected output.

Pre-requisites
Before you start with the set-up, please ensure these steps are completed.
Install CloudFiles in Salesforce
CloudFiles is available on the Salesforce AppExchange and can be installed using the standard app installation process. Check out Installation guide to know more.

Connect your Cloud Storage to Salesforce using CloudFiles
All automations in CloudFiles are activated through Salesforce Flow Builder, utilizing account-wide authentication for external storage libraries through a service (admin) user. To connect your service user, access the setup, click on the external storage of choice and log into your account. For detailed steps, refer to the GIF below for a clearer understanding.

Add CloudFiles Widget to Lead record page
Add the CloudFiles widget to Lead record page in order to view the files and folders within salesforce. Follow the steps below -
- Go to any Lead record and click "Edit Page" Button.
- Lightning builder for this page will open. Insert a new tab and drag and drop the "CloudFiles" widget.
- Save and exit the builder. Refresh the Salesforce record page. The widget should now show up.
Refer to the GIF below to get a visual understanding of this step. The inserted widget may show a blank screen but you don't need to worry about it. Move on to the next step.

Automatic folder creation for Leads
For this tutorial, We require automated folders to be created upon the creation of new Lead. To accomplish this, we will create two distinct record-triggered flows using CloudFiles actions. For a comprehensive guide on the process of creating automated folders, please refer to our tutorial at Create Automated Folder Hierarchies for Managing External Files from Salesforce Objects
This is how the flow would look like -

Configure the CloudFiles Widget to Add a Custom Resource Action Button and Link It to the Flow
In this section, we'll walk through how to configure the CloudFiles Widget to add a custom Resource Action button and link it to the Flow we are going to create in the next steps.
You'll learn how to:
- Set up the Resource Action within the widget configuration.
- Link the action to your autolaunched Flow with the appropriate input variables.
Once the configuration is complete, copy the generated Widget Configuration ID and paste it into the CloudFiles widget settings on the Lead record page in Salesforce. This step ensures that the correct Resource Action button appears in the widget, allowing users to trigger the archive functionality.
Setting Up Widget Flow Actions in CloudFiles Widget
Follow these steps to configure Resource Actions in the CloudFiles widget -
Step 1: Open Widget Configuration
- Navigate to the CloudFiles Document Management App.
- Open the "Widget Configuration" page.
Step 2: Locate Resource Actions Section
Scroll to the bottom of the page, where you'll find the Resource Actions section. Refer to the image below for a visual understanding -

Step 3: Specify Attributes for Actions
For each List Action, provide the following details:
- Label – This is the name that will appear on the widget button (e.g., Archive).
- Flow URL – The URL of the Flow you want to trigger, including input variables.
- Flow Type – Choose the type of Flow from the dropdown. For this tutorial, select: Autolaunched Flow
flow/Archive_File_or_Folders?resource={!resource}&recordId={!recordId}In this example:
- {!resource} refers to the specific file or folder from which you are invoking the flow through the custom Resource action.
- {!recordId} is the Salesforce record (Lead) from which the action is being triggered.
Step 4: Save and Link the Widget
- After entering all configuration values, click Save.
- Copy the generated Widget Configuration ID.
- Navigate to the Lead record page in Salesforce and paste this ID into the CloudFiles widget configuration panel.
This step enables the Resource Action button to appear within the widget, allowing users to move the file or folder to the Archived folder with just a click.

Flow – Move a Lead File or Folder to an Archived Folder Using the CloudFiles Resource Action
In this section, we'll create a Custom Resource Action-driven Flow to move folder or files into the Archived folder based on specific business rules — for example, if you want to move a folder to archived storage after a certain period of inactivity or elapsed time.
We'll configure an Autolaunched Flow (no trigger) that runs when the user clicks the Resource Action button next to a specific file or folder in the CloudFiles widget.
The flow will:
- Create a parent folder named after the Lead inside the centralized Archived location in your external storage.
- Move the specific file or folders into that Lead-specific archive folder.
- If a folder with the Lead's name already exists in the Archived location, the Flow will reuse it and place the selected content inside—ensuring organized and non-duplicative storage.
This is how the final flow looks like -

The details of the flow has been given below -
1 - Configure a Autolaunched Flow
We'll begin by creating an Autolaunched Flow (No Trigger) to handle the logic for moving file or folder to the Archived location. Follow the detailed instructions below to configure the required input parameters:
- After Created a Autolaunched (No-trigger) flow create a input variable called recordId to get a record id from the lead record page
- Then create a resource variable to get the selected resource from the CloudFiles Widget.
Create Flow Variables
To pass selected resource (file/folder) and the current record ID to the flow, create the following two variables -
- resource:
- Type - Variable
- Data Type - Apex Defined
- Apex Class - clds__Resource
- Allow Multiple Values (Collection) - False
- Available for Input - True
- recordId:
- Type - Variable
- Data Type - Text
- Allow Multiple Values (Collection) - False
- Available for Input - True
The GIF below provides a visual understanding of this step -

2 - Get details of the Lead folder
We will use Get Connected Folder Apex action to retrieve the details of the folder connected to the current Lead record.
Once you add the action to your Flow, it will prompt you to provide a single input parameter:
- ParentId – This is the Salesforce Record ID whose connected folder needs to be fetched. In this case, use the {!recordId} variable (which we configured as Available for Input) to pass the current Lead's Record ID into the action.
We will use this folder information in the next step to move the respective file or folder into the appropriate folder under the Archived location.
Refer to the GIF below to get a visual understanding of this step.

3 – Get Lead Folder Details in the Archived Location
We will use Get Resource Details apex action to retrieve the details of the Lead folder that resides inside the Archived location in your external storage.
Once you include this into your flow action, it will ask you to fill in these parameters:
1 - Drive Id
- This is required for Google Drive and SharePoint libraries.
- Input the Drive ID where the Archived folders are stored.
- You can get the Drive ID from the CloudFiles Content Library tab inside the CloudFiles app in Salesforce. Alternatively, you can use the Drive ID output from another action earlier in the Flow.
In this tutorial, since we already retrieved the Lead folder details in Step 2, we can reuse the output from that step. Use: Get_Lead_Folder > Drive Id
2 - Library
This is the desired Cloud storage where you wish to create the folder. Possible values are sharepoint, google (for Google Drive), onedrive, dropbox, box, cloudfiles (AWS S3).
In our case, the folders reside inside SharePoint, so we will set the input value to: 'sharepoint'.
3 - Resource Id
This parameter is conditionally optional.
- If you don't know the Resource Path, you should provide the Resource ID.
- However, in this tutorial, we do know the path to the Lead folder inside the Archived location, so this can be left blank.
4 - Resource Path
- This is also a conditionally optional parameter but required in our case since we don't have the Resource ID.
- Provide the full path to the Lead folder inside the Archived directory.
Our input will be a formula variable named {!folderPath}, which contains the following string-type formula: /SF Documents/_Archived/& {!Get_Lead_Folder.name}
Example input: '/SF Documents/_Archived/CloudFiles India Private Limited'
5 - Resource Type
This is an optional parameter. Since we are retrieving a folder, set the value to: 'folder'.
Refer to the GIF below to get a visual understanding of this step.

4 – Collect the Lead Folder ID Residing Inside the Archived Location
In this step, we will store the ID of the Lead folder that resides inside the Archived location of your external storage. This folder ID will be saved into a String-type variable called {!FolderId}, which will be used in the following steps to move files or folders into the archived structure.
Handling Two Scenarios:
Scenario 1: Folder Already Exists in the Archived Location
If the Get Resource Details action from Step 3 successfully finds the Lead folder in the Archived location:
- The folder's metadata (including its ID) will be returned.
- Use an Assignment element to store the folder's Id from the action output ({!Get_Archived_Lead_Folder_Details.id}) into the {!FolderId} variable.

Scenario 2: Folder Does NOT Exist
If the folder does not exist in the Archived location:
- The Get Resource Details action will throw an error.
- Handle this with a Fault Path, where you'll:
- Use the Create Folder apex action to dynamically create a new folder using the Lead's name.
- Place the new folder under your desired archived location.

After creation:
- Capture the newly created folder's ID from the Create Folder action's output.
- Assign it to the same {!FolderId} variable, so you can maintain consistent logic across the Flow.
- Connect the fault path back to the main flow by linking it to the next logical element—ensuring that both success and error paths lead to the same downstream steps.
This step ensures that regardless of whether the Lead folder already exists in the Archived location or needs to be created, you'll always have a valid folder ID ({!FolderId}) to use in the next action.
Refer to the Image below to get a visual understanding of this step.

5 – Move the selected resources to Archived Loaction
In this step, we will configure the logic to move a file or folder to the Archived location using the Move Resource flow action, triggered by clicking the button next to the respective resource.
Move Resource – Apex Action Configuration:
1 - Library
This is the target cloud storage provider where the resource should be moved. Possible values are sharepoint, google (for Google Drive), onedrive, dropbox, box, cloudfiles (AWS S3).
In our case, we can dynamically input this value from the resource variable itself using: {!resource.library}.
2 - Drive Id
- This is required for Google Drive and SharePoint libraries.
- Input the Drive ID where the selected resources are stored.
In this tutorial, since we already have access to the resource variable provided as input from the widget, we can directly use the Drive ID from it{!resource.driveId}.
NOTE - If you are using google drive or sharepoint, the Move Resource action can only move those files/folders which exist in the same drive. Simply said, you cannot move files/folders across Drives.
3- Resource Id
This is the ID of the resource that needs to be moved. In this tutorial, since we already have access to the selected resource, we can directly use the Resource ID from the variable {!resource.id}.
4 - Resource Type
This is the type of the resource which is to be moved, whether it's a 'folder' or 'file'.
Valid Inputs for this parameter:
- folder if the resource you want to move is a folder.
- file if the resource you want to move is a file.
In this tutorial, since we already have access to the selected resource, we can directly retrieve the Resource Type from the variable {!resource.type}.
5 - Destination
This is the Id of the folder in to which the resource is to be moved. To be more specific, this is the 'Resource Id' of the folder into which the resource (the resource whose Id has been input in the 'Resource Id' parameter) is to be moved. Since we've already collected the Lead's folder ID (which resides inside the Archived location) into the variable {!folderId}, we can directly use this as the destination to move the selected resource into the corresponding Lead folder.
Refer to the GIF below to get a visual understanding of this step.

6 - Save and Activate the flow
Once the Flow is activated, you can proceed to create a widget configuration and set up a Resource Action button within the CloudFiles widget. This will allow users to access the configured Resource Action directly from the Lead's record page.
Using this button, users can trigger the Flow to move a file or folder into the appropriate Archived location—all directly from within the CloudFiles widget.
Test it in action
To test the complete functionality, follow the steps below:
- Create a New Lead Once the Lead is created, the folder structure will be automatically generated by the pre-configured flow responsible for Lead folder creation.
- Upload Files to the Lead Folder Using the CloudFiles widget on the Lead record page, upload some test files and folders into the newly created Lead folder.
- Select and Archive Unwanted Files or Folders Suppose you've reached a certain stage in the Lead lifecycle and no longer need some of the uploaded resources. Simply click the Resource Action button beside the unwanted file or folder in the CloudFiles widget to archive it using the custom Resource Action you configured earlier.
- Verify the Move in the Widget After triggering the Resource Action, you'll notice that the resource is no longer visible in the CloudFiles widget on the Lead record. This confirms that the move action has taken place successfully.
- Confirm Archival in External Storage Now, go to the CloudFiles Document Management App and navigate to the _Archived folder location in your connected external storage (e.g., SharePoint). You will find a new folder named after the Lead, and inside it, all the selected files and folders will be stored—indicating successful archival.
Flow execution and folder creation may take some time (a few seconds to a minute). If you don't see any changes, try refreshing the CloudFiles widget a couple of times.
Congratulations! You've successfully set up a custom Resource Action button in the CloudFiles widget, allowing users to seamlessly move unwanted Lead files or folders into a centralized Archived folder in your external storage. You've also configured the supporting Flow to trigger this action based on specific business conditions—such as before converting a Lead or after reaching a certain stage—helping keep your Salesforce records clean, organized, and audit-ready.