Lightning Flow Builder – Decision Element
The Decision Element is one of the most important elements we have in Lightning Flow Builder. It is the only way we can add logic and pathways to our Flow automation. Unlike Screen elements, Decisions can be used in both Screen and Autolaunched flows.
With Workflow rules, we can add a single set of logic, when the rule should fire its actions. Process Builder expands on this logic. In addition to specifying when actions should be fired, in some circumstances, you can add additional logic. For example, when updating related records as an action, you can specify the criteria the related record must have in order to get updated. Flows allow even more complicated logic. We can add a decision to split the flow of automation.
Unlike Process Builder and Workflow rules we can create many different pathways in our logic. A decision element will always have at least 2 pathways – one based on criteria and a second as the default or “catch all.” You can add additional outcomes to a decision element. You will always have a default outcome. This is the path your flow will take when none of the other outcomes match the criteria being evaluated. In this Lightning Flow example, you’ll see how to use the Decision element, create outcomes, and some use cases.
Decision Element Uses
- Split the path of the Flow. This is great for “If a user selects picklist value 1, send them to screen 1. If the user selects picklist value 2, send them to screen 2.” and so forth.
- Check Input values. You may be passing values into your resources when the Flow starts. This is very common with Auto-launched flows. Your flow will likely be dependent upon having a value in those resources. I like to have a decision element immediately at the start to ensure that everything I expect to have been passed in has well been passed in. This way if I’m missing something I can error gracefully versus getting a big ugly error message
- Check Get Records elements. One of the frustrating things that many Flow users is not checking that Get Records elements found records. It may work 9 out of 10 times. On that 10th time, if your flow assumes you have records and you don’t, you’ll get a nasty error. Using a decision element to check you have found records allows you to have a graceful error or “fault” path.
- Ending Flow early. There may be circumstances when you simply want the automation to stop. This could be because of an error (like in use case #3) or because the user doesn’t have the custom permission to let them use the automation. A decision doesn’t have to have a continued path. It can simply stop.
Video
This series of Wizard’s Apprentice will focus on a gradual review of the Lightning Flow Builder and Flow concepts to help make you be an automation wizard! Make sure you’ve watched our Lightning Flow Builder Overview episode since this expands what was already covered.
https://www.youtube.com/watch?v=oyNjoUTd9XA
Check out other Wizard’s Apprentice videos:
Screen Flows:
Lightning Flow Builder Screen Flows Wizard’s Apprentice Episode 2
Wizard’s Apprentice Lightning Experience – Sobject Variables, Collections & Loops Revisted