Reactive Formulas in Flow
A new (beta) feature coming in Summer ’23 relase of Salesforce is the use of reactive formulas in Flow. Instead of having to navigate to the next page to see the result of a calculation, you can add a reactive formula that will “react” or recalculate on the fly!
Let’s take a look at how that can work to calculate your final exam score on a Salesforce Administrator exam.
When you sit the Admin exam, at the end you get a breakdown of the section scores and a pass/fail rating. But what was your actual score? If 65% or above, you pass, below that you failed. But failed by how much? How close were you to passing?
If we take a look at the Exam Outline, here: https://trailhead.salesforce.com/help?article=Salesforce-Certified-Administrator-Exam-Guide as it gives us those weightings for each section.
We can see the weighting for each section of the exam.
When you get the email with your final results, you will get the percentage you achieved for each section. (but no total).
Here is where we can build a screen flow to calculate the actual score on the exam.
- You must be using a pre-release org (or already be on a Summer ’23 release – May/June 2023)
- Enable the Opt in to Reactive Screens Beta function under Setup -> Process Automation Settings
- Your flow must be using API verstion 58 or higher (Summer 23).
Create a new screen flow
Give the initial flow screen a name and add a line of instructions.
Next, add a slider component for each of the section scores:
Just give each of the 7 sliders an API name and a label, leaving all the other settings as default.
I have added a section into the screen so I can have a two column display. You can do this or just stack them one on top of another in a single column if you prefer.
Create Formulas for section scores
Next, we need some formulas to calculate each of the 7 weighted section scores.
Each formula is similar, it takes the value of the slider and multiplies it by the weighted percentage. For example the Configuration and Setup is worth 20% so we multiply the value by 0.20 to get a weighted score for that section of the exam.
The weighting of each section is as follows:
- Configuration and Setup – 20% (multiply by 0.20 in the formula)
- Object Manager and Lightning App Builder – 20% ( * 0.20)
- Sales and Marketing Applications – 12% ( * 0.12 )
- Service and Support Applications – 11% ( * 0.11)
- Productivity and Collaboration – 7% ( * 0.07 )
- Data and Analytics Managment – 14% ( * 0.14 )
- Workflow / Process Automation – 16% ( * 0.16 )
Create a new formula for each of these seven (7) values.
Create an Exam Total formula
We then need another new formula that will add all these formulas and provide our exam total score:
Now we go back to the screen element and add in the total formula (Exam_total).
Normally we would use a display text field to display this result but as that component is not supported in this Beta, we use a little trick!
We don’t want the value to be an input field, but to be a read only result on the page, so we will use the URL field (which has a read only attribute).
Set the field to Read Only (1) and set the value to the Exam_total formula (2):
Save the flow and run in debug mode to see the results.
When you have selected a value for each slider, the total exam score will be displayed.
You can go back and adjust the section scores and the total exam score will dynamically be adjusted too.
There are restrictions and considerations that apply, check those out here: