Introduction
In this article, we explore the 'Copy Files to External Storage' flow template that comes packaged with the CloudFiles app. We will quickly cover what this flow template can be used for, and will then talk about how to set it up.
This article is divided in the following sections -
- What can this flow do - In this section we talk about what this flow can be used for. Using the various variables discussed below, this can be highly customized.
- Pre-requisites - A couple things you must ensure have been done before using this flow template
- Creating flow using this template - This is a quick, 1-minute starter step to create a new flow using this template
- Setting Target Object - In this section we make a couple of changes in our flow to trigger it only when we upload files to notes & attachments section of Accounts.
- See it in action - We finally turn our flow on and test it out in this section.
Check these sections below for more information.
What can this flow do?
The 'Copy Files to External Storage' is triggered by a Salesforce platform event that occurs when a file is uploaded into the notes & attachments section of any Salesforce object. Once triggered, the flow checks if the upload was done on the target Salesforce object (e.g. Account object). If so, the flow uploads that file into the connected external folder of that Salesforce object.
As shown in the screenshot below, the flow uses a number of standard Salesforce actions in addition to the CloudFiles' Upload to External Storage action to achieve. The logic and variables of the flow can be modified as per your business use-case as explained in the next sections.
Step 1 - Pre-requisites
Before using this flow template, make sure you have done the following 3 things -
- Installation & Setup - Make sure you have followed steps 1 to 3 in the installation guide. This includes installing the Salesforce app in production or sandbox, connecting CloudFiles account and setting permissions.
- Connected Folder Widget Setup - Make sure you have the 'Connected Folder' widget setup on one of your Salesforce objects. This is shown in Step 1 in this article. The connected folder of the record is where the final uploads would go to.
- Link a folder on your test object - Choose an appropriate target object, go to the Connected Folder widget of that object and manually link a folder from your cloud storage as shown in step 2 of the above article. This step can also be automated as shown in step 4 of the above.
That's it, now lets create a new flow using this template.
Step 2 - Using this template in a new flow
You can create a new flow using the 'Copy Files to External Storage' template. This clones the flow template and replicates all the variables so that you can set them up later. Follow the simple steps below -
- Go to Salesforce Setup > Flows
- Locate & click the 'CloudFiles: Copy Files to External Storage' flow. This is created by the package and is not active by default, so make sure to check your list filters if you don't find this.
- Click on Save As in the top right.
- Give your flow a name and save it. The template flow will get cloned.
These steps are shown in the GIF below -
Step 3 - Set Target Object
We need to determine a target Salesforce Object. The flow will trigger when any file is uploaded in the notes & attachments section of the target object. For the purpose of this article, we have used the Account object. Follow the simple steps below -
- Click on the 'Is Correct Record?' Decision action. Edit the element.
- In the value field on the next screen, enter the API name of the target object
You can add more branches on the above step to include more object types provided you have connected folder widgets setup on all those folder.
That's pretty much it. The connected folder does all the heavy lifting of determining the folder, drive & libraries. You can now test this out as we did in the next section.
Step 4 - See it in action
To test out our final flow, we will save and activate it. We have setup our variables such that the flow will trigger when we upload a file on the Account's notes & attachments section. The working flow is shown in the GIF below -
<gif for working flow>