Tutorials
Document Management Tutorials

Move Lead folder to Account folder on conversion

in this tutorial, we'll guide you on moving lead folders into their respective account folders in any external storage automatically on conversion of lead we will use cloudfiles flow actions to create these automated folders what to expect by the end of this tutorial, you can expect to have an account folder created in your external storage for every new account have a lead folder created in your external storage for every new lead automatically move lead folders into their respective account folders on conversion of lead the gif below shows the expected output pre requisites 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 account and lead record pages add the cloudfiles widget to account and lead record pages 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 follow the above steps and add cloudfiles widget to the lead record page as well 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 accounts and leads for this tutorial, we require automated folders to be created upon the creation of both new account and 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 flow move lead folder into account folder on lead conversion in this section, we will create a flow to automatically move the previously created lead folder into the corresponding account folder upon lead conversion firstly, we'll configure a record triggered flow to initiate the automation process then, we'll retrieve the details of the lead folder to ensure that the account folder has been created, we'll implement a pause subsequently, we'll gather details of the account folder finally, using cloudfiles action, we'll execute the movement of the lead folder into the associated account folder this is how the final flow looks like the details of the flow has been given below 1 configure a record triggered flow we will start by creating a record triggered flow on the 'lead' object follow the detailed instructions below for the input parameters in the 'configure start' window, select lead as the object configure trigger of the flow when a a record is updated for setting the entry conditions, follow the following steps condition requirements > select all conditions are met (and) define the condition as field > isconverted, operator > equals, value > true for when to run the flow for updated records, select only when a record is updated to meet the condition requirements we have selected this option since we want the flow to run only when the triggered record is changed from not meeting the entry conditions to meeting the entry conditions above conditions ensure that the lead folder moves to account folder only once when the conditions for the lead's conversion are met for the first time for optimize the flow for, select actions and related records check the include a run asynchronously path checkbox the configuration looks like below the gif below provides a visual understanding of this step note in record triggered flows, make sure you run cloudfiles actions only in 'run asynchronously' path 2 get details of the lead folder we will use get connected folder docid iq8rljf2ne8sx0 iuu apex action to retrieve the details of triggering record's corresponding lead folder once you add the action, it will ask you to fill in a single parameter parentid input the salesforce record id whose connected folder is to be fetched here, input the flow triggering lead record id as 'record' > 'lead id' i e {!$record id} refer to the gif below to get a visual understanding of this step in case the salesforce record, whose id is input into the action has got a single folder attached to it, then get connected folder docid iq8rljf2ne8sx0 iuu will give the attached folder details as output here, by inputting the record id of the lead that triggered the flow, the action yields the details of he folder attached to the lead record we will use this details in the next step to move the lead folder to account folder 3 pause to ensure account folder creation to ensure seamless execution and prevent flow errors, a delay element is introduced into the flow this delay accommodates potential delays in the execution of the pre requisite flow responsible for creating and attaching the account folder, which occurs concurrently with the conversion of the lead record by incorporating this delay, we mitigate the risk of fetching incomplete or erroneous account folder details before the completion of step 1 add a ' cloudfiles delay ' apex action into the flow, positioned after the 'get lead folder' element and before retrieving details of the corresponding account folder in the subsequent action the 'cloudfiles delay' apex action functions as a 'pause for a given time' element before the flow proceeds to execute the next action or element once you add the 'cloudfiles delay' apex action, it will ask you to fill in a single parameter delay(milli seconds) the amount of time the pause acts for in milliseconds refer to the gif below to get a visual understanding of this step note avoid setting a long pause duration as it may result in flow timeouts and errors for this specific flow, a delay of 10,000 15,000 milliseconds should suffice 4 get details of account folder we will again use get connected folder docid iq8rljf2ne8sx0 iuu apex action, this time to fetch the details of triggering record's corresponding account folder once you add the action, it will ask you to fill in a single parameter parentid input the salesforce record id whose connected folder is to be fetched here, input the flow triggering lead record's converted account id as 'record' > 'converted account id' i e {!$record convertedaccountid} refer to the gif below to get a visual understanding of this step here, as we input the converted account record id of the lead that triggered the flow, the action outputs the details of the folder attached to the account record in the next steps, we will see how this is useful 5 move lead folder into account folder move resource docid\ sviadh0nd9uf2vdufxwmm action can be used in a flow to relocate a resource (file or folder) in any cloud storage from one location to other once we have fetched the details of lead folder and account folder in our previous steps, we will add a move resource docid\ sviadh0nd9uf2vdufxwmm apex action to move the fetched lead folder from step 2 into the fetched account folder from step 4 once you add the action, it will ask you to fill in these parameters 1 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) 2 drive id this is required only for google drive & sharepoint libraries input the drive id in which the folders are stored for this you can simply enter the 'drive id' in which the account folders and lead folders are stored you can get this parameter by accessing your cloud storage from within salesforce , using cloudfiles app's 'content library' tab or you can even use the 'drive id' output by other actions in the flow in this tutorial, in step 2 and step 4 as we already added actions to output the lead folder details and it's account folder details, we can use any of these action's output to input this parameter as 'get account folder' > 'drive id' or 'get lead folder' > 'drive id' 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 the id of the resource which is to be moved for this you can use the outputs of other actions in the flow in this tutorial, as we want to move the lead folder (this folder is the resource to be moved), input the 'resource id' output by the action you have added in step 2 as 'get lead folder' > '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 are moving a folder (lead folder), input folder 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 you can get this parameter by accessing your cloud storage from within salesforce , using cloudfiles app's 'content library' tab or you can even use the outputs of other actions in the flow in this tutorial, as as we want to move the lead folder into account folder (destination), input the 'resource id' from the output of action added in step 4 as 'get account folder' > 'resource id' refer to the gif below to get a visual understanding of this step 6 save and activate the flow once the flow is activated, whenever a lead is converted into a new account or existing account , this flow should automatically move the triggering lead record's lead folder into it's converted account folder test the flows in action now that everything is setup, lets test our flows follow the steps below to see this automation in action create a new lead this should create a lead folder visible in the 'cloudfiles' widget on lead record page click 'convert' on the lead record in the 'convert lead' form, for account, choose 'create new' or 'choose existing' (if you are choosing this make sure you have a folder connected to account record) once converted, check the account folder visible in the 'cloudfiles' widget on account record page you will find the lead folder moved into the account folder 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 configured flows to automatically move lead folders into their respective account folders on conversion