Tutorials
Document Management Tutorials

Create Automated Folder Hierarchies for Managing External Files from Salesforce Objects

in this tutorial, we'll guide you on creating automated folders and sub folders in any external storage directly from any salesforce object using cloudfiles salesforce integration we will use cloudfiles flow actions to create these automated folders if you have a basic grasp of salesforce flows, you can expect to finish the tutorial in under 10 minutes what to expect by the end of this tutorial, you can expect to create an account object and have a folder created for it automatically in your backend storage have sub folders created inside the account folder as per your custom requirement you will be able to see these folders and sub folders from your record you will also be able to do various file & folder operations such as upload, preview, delete, edit etc right from the record the gif below shows the expected output our final setup involves a couple of flow actions added to a salesforce flow as shown below in the sections below, we cover each of these actions and how to configure them tutorial video refer to the quick video if you would like to have a visual guide for this tutorial read on if you prefer textual content 1 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 2 create account folder using ‘create folder’ action “ create folder docid\ xrardogtcdiogtagjunnl ” action can be used to create folders in any location on any cloud storage platform from salesforce flows we will use this action to first create the account’s parent folder important if you use a record triggered flow, make sure you run this action on an asynchronous path as shown below create a new flow in your salesforce org, select the trigger and add an asynchronous path as shown in the gif below we will then add cloudfiles flow actions on the asynchronous path to use the “create folder” action, simply click on add element button on the asynchronous path and search for ‘create folder’ as shown below once you add this action, it will ask you to fill in certain parameters this action requires a few parameters the library parameter 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) the folder name is the name you wish to give your created folder we simply use the account’s name but you can also create a complex text formula variable as well we also need to enter values for drive id & parent folder id this is covered in the next section the gif below shows how to populate the library & folder name parameter 3 configure destination parameters in flow action in the 'create folder' action, there are a few other parameters that help specify where the target folder should be created e g in sharepoint, which site, drive and parent folder should this folder get created in here is a quick reference of destination parameters parent folder id this is the cloud drive generated id of the folder where you want to create this account folder in drive id this is important for google drive & sharepoint users only these cloud storages offer multiple 'drives' where documents can be uploaded these parameters can be easily copied from within salesforce using the cloudfiles content library tab follow these steps click on app launcher on top left search for the “cloudfiles” app in the cloudfiles app, select the content library tab go to your preferred cloud storage go to the target folder where you would like to place the created folders in click on ‘view metadata’ button as shown below a dialog box opens up which shows all the ids copy the id from here check the gif below for a quick walkthrough of these steps for a detailed description of the create folder action, refer to the create folder docid\ xrardogtcdiogtagjunnl detailed guide this flow action returns various values related to the newly created folder we will use the newly created folder’s id in the next step to create a sub folder here’s how our final create folder action looks like 4 create sub folders using ‘create folder‘ action to create sub folders, we can simply use the same ‘create folder’ action that we used above with a couple of simple tweaks change the ‘folder name’ to reflect the sub folder you want to create we are creating ‘proposals’ sub folder inside our account folder change the ‘parent folder id’ to the return value of the previous create folder action this way, this new folder will get created inside the account’s folder we created previously here’s how your second create folder action should look like you can choose to have as many sub folders as you want simply duplicate the create folder action you can also create sub sub folders and even deeper hierarchies using this method if you have very large or complex folder structure, we recommend using folder cloning method instead now that we have parent and sub folders created, we want all of this to show up on the salesforce record we will use the ‘create attachment’ action to associate the account folder to the salesforce account record later we will use the cloudfiles widget to actually see and manage the folder from the record 5 show folder on record using ‘create attachment’ action create attachment action allows you to attach the created folders and sub folders to salesforce record attaching (or associating) our newly created folder is important since this will enable us to see and operate on the folder contents right from the salesforce record to use this action, simply click on add element button and search for ‘create attachment’ as shown below once you add this action, it will ask you to fill in certain parameters “drive id” and “library” parameters will be same as above add the remaining parameters as given below resource id id of your parent folder you can get it from the output of your first “create folder” action (the one we created in step 2 above) resource type simply use the string 'folder' for this (without quotes) salesforce record id id of the salesforce record → {!$record id} that's it now our flow configuration is complete save and activate the flow refer to the gif below to get a visual understanding of this step here’s how our final create attachment action looks like 6 add cloudfiles widget to account record now that folders and sub folders are created and attached to the record, we will add the cloudfiles widget to the account record in order to view the files and folders within salesforce follow the steps below go to any account 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 will show a blank screen but you don't need to worry about it move on to the next step 7 test the automated folders in action now that everything is setup, lets test our flow follow the steps below to see this automation in action simply create a new account record in salesforce and then go the ‘files’ tab that we added in the previous step the flow may take a few seconds to run so click on the refresh icon on top right of the widget once the folder is connected, the system might show you a “connect to sharepoint” button as shown below this is a one time login that your users will need to perform the first time they access cloudfiles using salesforce once you connect your sharepoint here, you should see the newly created folder and the sub folders inside you can quickly navigate to sharepoint as shown below these steps are illustrated in the gif below congratulations! you've successfully created an automation to create custom folder and sub folder hierarchies using salesforce flows we have shown only a very specific part of this automation for the sake of speed however you can customize these flow actions to a high degree to replicate any process imaginable