Visual Workflow allows us to automate business processes by building applications, known as Flows. Using Flows, a user can collect information; or, they can update, edit, or create records in Salesforce. Furthermore, Flows can execute logic, interact with the Salesforce database, call Apex classes, Platform Events, and guide users through various screens to streamline the process of collecting and updating data. Once a Flow is built, an Admin can make the Flow available to the right users or systems.
Before Spring’18 release, it was not possible to attach a file from a Flow. For example, if you build a Flow that allows your sales rep to create a Contract you would also want them to attach a Contract PDF file through a Flow. Before Spring’18 release, however, it was not possible to attach a PDF file via a Flow.
After Spring’18 release, however, with just a few clicks, users can now attach files Contract, or other Objects, via a Flow! An Admin can allow users to upload files from a Flow by adding the File Upload (forceContent:fileUpload) Lightning component to a Flow’s screen, as shown in the following screenshot:
Furthermore, an Admin can also customize Accepted Formats in a Flow to further specify which image file formats a user can upload. However, note that, any files, that are either non-images or are not in the Accepted Formats, cannot be uploaded! This change applies to Lightning Experience and Salesforce iOS app. Also important to note here is that the File Lightning Component works only for Flows that use Lightning runtime.
In this article, I am going to show you how one can use File component in a Flow and then make it available to business users. Let us start with a business use case.
Business Use Case
Edward Backhouse is working as System administrator at GurukulOnCloud. He received a requirement from upper management to create a Flow that allows reps to create Leads and upload their business cards from it. The requirement also includes following asks:
- Reps must be able to upload multiple Business Cards of prospects that belong to the same company
- And, secondly, the Reps must only be able to upload files of type .jpg, .png and .Pdf.
Solution for the above business requirement
There are a few possible solutions for the above business scenario. For example, you can use Evernote or similar applications – that allows a user to scan business card from mobile and auto create leads into Salesforce. However, our purpose, in this blog, is to learn Flow and its advanced/new features. Therefore, we will use Flow and new File lightning component to solve the above business requirement. To do so, follow the steps listed below:
- Navigate to Setup (Gear Icon) | Setup | Process Automation | Flows in Lightning Experience.
- Then click on the New Flow button – it will open the Flow canvas for you.
- Create a sample Flow (add two text fields to it to store LastName and Company) as shown in the following screenshot: –> Remember, to create a Lead we need LastName and the Company information of prospects; for, these are required fields! However, feel free to add more fields if your use case calls for additional fields.
- The next step is to use Record Create element to insert the above lead into Salesforce. Click on the Palette tab and drag and drop the Record Create element onto the canvas; it will open a new window for you. Map the Record Create element according to the following screenshot:
- The next step is to add a File Upload Lightning component to our flow.
- Add one more screen element to your flow.
- On the Screen element, navigate to the Add a Field tab and double-click on the Lightning Component field, to add it on to the Screen element, as shown in the following screenshot:
- On the Screen overlays preview pane, click on the [Lightning Component] field to configure its settings, as shown in the preceding screenshot.
- For the Lightning Component drop-down on the Field Settings tab, select forceContent:fileUpload.
- You can pass values between the flow and the component by using the Inputs and Outputs tabs. In the end, your File component will look like the following screenshot:
- In the end, your Flow will look like the following screenshot:
- Save the Flow (Type: – Screen Flow) with name Upload File – Test and close the canvas.
- Don’t forget to activate the Flow by clicking on the Activate button.
It’s time to test this feature
Now users can attach files to a flow from any device (Salesforce iOS or Android).
If you have any problem with watching the video then, please click on it and open it in another tab.
I hope you can learn from the blog about how to upload files from a Flow!! Yes, go ahead! Show off your newly acquired skills to your friends, colleagues, and families!
Please feel free to add constructive comments, insights – and yes, challenges too! – to the blog. Good Luck in your Journey towards becoming a Salesforce Ninja!
Technical Editor and Proofreader: - Munira Majmundar