Building Flows with the Lightning Flow Builder-Part 2
Hey Salesforce Geeks! In my previous blog I talked about the Lightning Flow Builder which replaced the Cloud Flow Designer within the Spring ’19 release. In my second post, I am going to show you how to build Flows using the Lightning Flow Builder.
With the Spring ’19 release, Flow Builder will be the default flow-building tool in all orgs, Salesforce Classic or Lightning Experience, so no migration is needed. If any existing flow is modified or a new flow is created, the Flow Builder will be opened.
Consider a simple business scenario: As a Bank Sales Representative (Sales Rep), I should be able to create a new Account opening for my client including Debit/Credit Card issuing with ease, automation and with minimal data entry and clicks.
There are a few possible solutions for the above business scenario. One way to do it is to use Cloud Flow Designer or write a trigger. I decided to use the Lightning Flow Builder to implement this business scenario. And it worked wonderfully for my Sales Reps!! There was no need to write any code and designing the flow was quick and easy.
Let’s look at the steps required to build Flows using the Lightning Flow Builder.
- Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
- Click on New Flow, it will open the Flow canvas for you wherein you build the actual flow by dragging-dropping the flow elements
- The Next step is to select the Screen element and drag-drop it into the Flow Canvas
- Set the Screen Properties
- Drag the text component onto the Screen from the Screen Component list and set the properties
Fig. Screen Element to get Account details
- After entering the Account details on the screen, the next step is to create an Account record using those details
- For this, add the Create Records element to the Flow
- Set the properties, number of records to be created (One/Multiple) and How to Set the Record Fields
- Select the Account object of which the record is to be created, set the field values and store the record ID in the variable (a flow variable)
Fig. Create Record element used to create an Account record
- Now that the Account record is created, we will provide the preference screen where the user can select the Contact or Opportunity object whose record needs to be created
- Select the Screen element and drag-drop it into the Flow Canvas
- Set the Screen Properties and then drag the Picklist component onto the Screen from the Screen Component list and set the Choices to be selected
Fig. Screen element with Choices set
- Based upon the Choice selected, a Contact record or an Opportunity record will be created
- The next step is to add Decision element which determines the next actions to be done based upon the choice the user has selected.
Fig. Decision element to determine next actions
- The Contact Record or the Opportunity record will be created based upon the values given in the screen variables using the Create Record flow element similarly as we did for Account record creation (refer the Create Record image)
Finally, the flow will look like this:
Fig. Complete Flow
- Save your flow with name Object Record Creation, select the type of the flow (Screen Flow in our case) and close the canvas. Don’t forget to Activate the Flow.
Debugging in Lightning Flow Builder
You can debug the flow using the Debug option provided in the flow and verify the flow functionality.
- The debug window shows the flow interview in the right-hand side. The flow interview includes record IDs and flow errors, if any.
- One can investigate the flow interview like the way we check the debug logs to resolve the issues
Fig. Debug Screen
- The Debug Screen takes the required inputs from the user and performs the flow steps
- A flow interview is seen at the right-hand side of the screen to analyze the flow actions and errors encountered
- Using the Run button, we can run our Screen flow and see the results.
Isn’t it convenient to use the Lightning flow builder? Let’s try various business scenarios where you could use the Lightning Flow and compare our experience in the comments below.