Automate This! Enhance Screen Flows with Reactive Components

Automate This! — Enhance Screen Flows with Reactive Components

By

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Michelle Hansen uses reactive screen flow components and Data Fetcher to build a single-screen sponsorship selection wizard that creates an opportunity complete with products.


Use case: Need a way to easily manage sponsor opportunities for an event

As part of the Midwest Dreamin’ planning team, I wanted to create a simple, wizard-like interface to help the team create opportunities for sponsorship more quickly and easily. We offer a range of Exhibit Booth options and other Sponsorships, as well as participation in the Demo Jam. We’ve also discussed offering discounts to sponsors who sign up early, so I wanted to prototype some options for how we might handle that as well. Finally, I wanted to make this flexible enough to work with leads that come in via our website as well as impromptu conversations that may happen where leads don’t exist. We have many sponsors who return year after year, so I also wanted to make it easy to find and choose existing accounts within the org as part of the process.

To solve this, I immediately turned to screen flows, but with the recent introduction of reactive screen components for Flow Builder, I was able to make this wizard even more elegant and user friendly! Let’s dive in.

Solution: A wizard powered by screen components

The wizard contains a series of steps on the first screen. Let’s review the inventory and then we’ll dig into how they all work together.

1. Select an Exhibit Booth

This step is powered by Flow’s native Data Table component. Before the first screen, I do a Get Records on the relevant Price Book Entries. Then, I use two collection sort and filter elements to break those Price Book Entries into Exhibit Booths and Sponsorships. Next, I use the sorted and filtered Exhibit Booth collection to populate the data table.

Participation in the Demo Jam is part of the top two exhibit booth tiers or is available as an add-on to the other tiers, which is offered only if one of the lower tiers is selected (as shown in the screenshots below). I support this with a Get Records on the Demo Jam Price Book Entry individually prior to the first screen, and referencing the unit price from the record.

At the bottom of the section are display text fields that show the selected exhibit booth and total amount.

Step 1: Select an Exhibit Booth with a data table that displays the booth type, price, number of passes, logo, description, and demo jam with Diamond Exhibitor selected.

Step 1: Select an Exhibit Booth with a data table that displays the booth type, price, number of passes, logo, description, and demo jam, with Gold Exhibitor selected and a toggle component to add Demo Jam showing that is not selected.

2. Select a Sponsorship

This step is also powered by Flow’s native Data Table component. I used the second sorted and filtered Sponsorship collection from the initial Price Book Entry collection to populate the data table.

At the bottom of this section are also display text fields that show the selected sponsorship and total amount.

Step 2: Select a Sponsorship with a data table that displays the sponsorship, price, number of passes, and logo placement, with Networking Reception Sponsor selected.

3. Discounts and Totals

The Step 3: Discounts and Totals section has an input field to hold the date by which the sponsor will be reminded about the payment for their sponsorship. There are also several display text areas that show the total of both the Exhibit Booth and Sponsorship steps, the calculated discount based on a supplied payment date, and a final total with the discount included. These dates are calculated based on a Custom Metadata (CMDT) record that is retrieved before the first screen as well. This CMDT holds information about Midwest Dreamin’, including the start and end dates and which year’s conference is active so the system knows which conference information to pull in.

Step 3: Discounts & Totals that shows the dates by which payment must be made to qualify for a discount, a field to enter the committed payment date, and prices calculated for the total Exhibit Booth and Sponsorship type, Discount amount, and Final Total.

4. Complete the Company Information

This section contains an input field which holds the Company Name if launched from a lead, a data table powered by Data Fetcher that returns a list of companies that match what is entered into the Company Name field, if any, and other fields needed to create a new Account. Until an existing account is selected in the data table, the additional fields needed to create a new account are displayed, and if no accounts match the criteria entered in the Company Name field, the data table is hidden.

Data Fetcher is a wonderful new component available on AppExchange that allows you to fetch records from the database by using a Salesforce Object Query Language (SOQL) query on a screen. Before this component was created, I would have had to use a Get Records to pull the list of records and another screen to display the data table using the records returned. Further, it wouldn’t have been able to restrict the list based on the input from a text field. This definitely is a game changer when it comes to how we can build screen flows!

Step 4: Complete the Company Information which shows the Company Name field filled out, the Billing Address fields with city, state, and country completed, and the website field filled out.

Step 4: Complete the Company Information which shows the Company Name field with an ‘s’, a data table displaying two accounts with ‘s’ in the name, and the Billing Address fields which are not filled out.

5. Add the Point of Contact

This section gives us an input field for First and Last Name that are prepopulated if the flow is launched from a lead and another data table. Using Data Fetcher, we return a list of contacts if an existing account was chosen in the previous section, filtered by the First and Last Name inputs. Just like before, if no matching contacts are found, the data table is hidden. The additional fields needed to create the contact are displayed unless an existing contact is selected.

The final display text field shows the Opportunity Name that has been generated based on the inputs from the screen just above the Create Opportunity button.

Step 5: Add the Point of Contact which shows the First Name field with ‘Br’, the empty Last Name field, a data table displaying two accounts with ‘Br’ in the first name, and the Email, Title, and Phone fields which are not filled out.

Step 5: Add the Point of Contact which shows the First Name, Last Name, Email, and Title fields completed, and the Phone field with only placeholder text. It also shows the Opportunity Name above a button labeled “Create Opp”.

Formulas make it reactive

The true power of reactive screen flows, though, comes from formulas! These formulas use the inputs from our various screen components and react as soon as those inputs change.

The first formula is part of the Exhibit Booth section. It displays the total price of the selected Exhibit Booth and the Demo Jam, if selected. The BLANKVALUE() function allows me to specify the value I want to display and a backup value in case the first one is blank. In this case, I want to display the Unit Price for the selected row in our data table, but before anything is selected, and therefore it’s blank, display 0. I then use an IF statement to add the Unit Price of the Demo Jam based on the value of the include Demo Jam toggle field. If it’s toggled to TRUE, add the Unit Price, and if it’s FALSE, add 0.

Side note: As of Winter ’24, Display Text fields (beta) are also reactive! This allowed me to leverage the formatting capabilities of display text fields in conjunction with formulas to really make the information pop on screen.

Flow screen components for the Demo Jam toggle, the Exhibit Booth label display text component, and the Exhibit Booth Total display text component.

Flow formula with API name “fmlExhibitBoothTotal”.

I used the same type of formula in Step 2: Select a Sponsorship to populate the Unit Price of the sponsorship selected in the data table.

Flow formula with API name “fmlSponsorshipAmount”.

Formulas are the driving force behind almost everything in Step 3: Discounts & Totals.

Screen components in Step 3: Discounts & Totals including display text for discount dates that includes formulas; a Committed Payment Date field; the display text fields for the Total Exhibit Booth + Sponsorship, Discount Amount, and Final Total labels; and the display text fields with formulas for each.

First, we use date formulas to calculate the pay by dates on the left-hand side based on the Conference Start Date from the Custom Metadata record for Last Day of the Prior Year, 5 Months Prior and 3 Months Prior.

The Last Day of the Prior Year formula uses the DATE() function to set the specific date. The nested YEAR() function allows me to take the year of the Active Event’s start date and subtract 1 to get the previous year, and then set the month to 12 and the day to 31. The other two formulas leverage the ADDMONTHS() function with a negative number to subtract full months from that start date.

Flow formula with API name “fmlPriorYearEnd”.

Flow formula with API name “fml5MonthsPrior”.

Flow formula with API name “fml3MonthsPrior”

The right-hand column contains formulas used to calculate the total of both the selected Exhibit Booth and Sponsorship, the discount amount based on the Committed Payment Date, and the final total after the discount is applied. For the purposes of this demo, I chose to hard code in the discount amount, but we could also hold these in variables and populate those variables in both the display text component and discount formula.

Flow formula with API name “fmlTotalSponsorship”.

Flow formula with API name “fmlDiscount”.

 Flow formula with API name “fmlTotalSponsorshipWithDiscount”.

The key formulas in Step 4: Complete the Company Information and Step 5: Add the Point of Contact are part of the Data Fetcher components on the screen. The “Choose an Existing Account?” Data Table is powered by the records retrieved from Data Fetcher. The Data Fetcher pulls records by running an SOQL query. This SOQL query is built with a formula that uses the input from the Company Name field to dynamically change the query. The LIKE operator with % signs at both front and back is basically the SOQL equivalent to a CONTAINS() function in formulas, so the results returned in the data table display every account where the input string is found anywhere in the Account Name, and those results change with each letter typed in that field, thanks to reactivity.

Flow formula with API name “fmlDFContactQuery”.

The final formula in Step 5: Add the Point of Contact displays the Opportunity Name that is created based on the Company Name from step 4, the selections from steps 1 and 2, and the Active Event Name.

: Display text field that contains the Opportunity label and the formula for Opportunity Name.

Flow formula with API name “fmlOppName”.

Converting an existing lead versus creating new records

Because I designed this with flexibility in mind, the next step after the screen is to decide if this was launched from a lead, in which case we’ll convert the lead into an account, contact, and opportunity under the assumption that this is a brand-new org that doesn’t have very many existing accounts so we aren’t creating duplicates. To do this, we leverage an Apex action in Flow that calls an Apex class that passes back. Once the conversion is done, I want to update the new account, contact, and opportunity with information from our screen since none of that is handled in our Lead Conversion action.

The Decision element “Launched from Lead?”, and the Convert Lead Apex action, Update New Account, Update New Contact and Update New Opp elements on the “Yes” branch.

If the flow was not launched from a lead, I use a couple of Decision elements to determine what to do next. The first Decision node evaluates if an existing account was selected from the data table, or if new account information was entered by the user. If an existing account was selected, I’ll update it with the Description provided in the screen. If a new account needs to be created, I’ll take all the values from the screen and use those to populate the appropriate fields. After that comes a Decision to determine if an existing contact was selected, in which case the screen information will be used to update that record, or if a new contact needs to be created instead. Next, the new opportunity is created using the Opportunity Name built by the screen inputs, the Sponsorship total as the Amount, and the Committed Payment Date as the Close Date, among other fields.

The Decision element “Launched from Lead?” and the “No” branch with another Decision, “Existing Account Selected?” with an Update Existing Account element on the “Yes” branch and a Create New Account element, both followed by an “Existing Contact Selected” Decision that has a “Create New Contact” element on the “Yes” branch, and finally a “Create New Opp” element.

Creating opportunity products

Finally, regardless of whether the records were created from scratch or through Lead conversion, the individual Opportunity Line Items (Opportunity Products) are created through a series of decisions to determine if one is needed for an Exhibit Booth, Demo Jam, Sponsorship, and/or a Discount based on the selections and formulas from the wizard screen.

The Decision “Exhibitor Selected?” and the “Create Exhibitor Booth OLI” on the “Yes” branch, and the Decision “Demo Jam Added?" with a “Create Demo Jam OLI” on the “Yes” branch.

 The Decision “Sponsorship Selected?” and the “Create Sponsorship OLI” on the “Yes” branch, and the Decision “Discount Offered?” with a “Create Discount OLI” on the “Yes” branch followed by a “Create Opportunity Products” element.

Success!

The last step of the flow is another screen that contains a success message and a link to the newly created opportunity.

The final screen with Display Text components showing a success message and Opportunity Name, Amount, and Close Date fields, and the display text “Go to Opportunity” with a hyperlink referencing a formula.

And that’s it. With the reactive screen flow components (powered by Data Fetcher), reactive formulas, and reactive display texts, I was able to make what would have been a 7+ screen flow—filled with back and forth navigation to calculate discounts, display information, and retrieve and display records—into a simple and elegant two-screen flow!

The full flow in landscape orientation.

Resources

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
Headshot of Kristi Brown next to text that says, "Automate This! — Power Up Your Einstein Bot with Flow."

Automate This! — Power Up Your Einstein Bot with Flow

Welcome to another Automate This! In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Kristi Brown tackles some everyday […]

READ MORE
Headshot of Eric Smith and text that says, "Automate This! — Make A Field Pop on a Record Page."

Automate This! — How to Make a Field POP on a Record Page

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. Automation allows you to remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Eric Smith used a custom […]

READ MORE
Automate This! with Jennifer Lee, Rebecca Glasser and Diana Jaffe

Automate This! — A Trailblazer’s Insights from Migrating Workflow Rules to Flow

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. Automation allows you to remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Rebecca Glasser migrates and consolidates […]

READ MORE