Tutorials
Document Management Tutorials
Enable Custom Actions in CloudFiles Widget: Build an Archive Button with Salesforce Flow
in this tutorial, we’ll show how to use the custom action functionality of cloudfiles to streamline file management directly from within salesforce custom actions in cloudfiles allow you to define clickable actions, like archive, send e mail etc , enabling users to trigger tailored salesforce flows for advanced automation and control without leaving the record page 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 docid\ fv1sn qekhvsae njyp6y 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, follow automations docid 4nyi6hnqnavp4dbjah tz or 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 docid\ ynzb pjpdnjkkttmq1p t 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 internal record widget guide docid\ rcwdmuwywxjr628vd20vr to add a custom widget flow actions in cloudfiles docid\ dk 1jq9encvg5qzcunybw 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 example flow url format 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 docid iq8rljf2ne8sx0 iuu 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 docid\ ue5s2y9qglsceiqd0serc 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 docid\ xrardogtcdiogtagjunnl 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 docid\ sviadh0nd9uf2vdufxwmm 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 docid\ sviadh0nd9uf2vdufxwmm 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