Skip to main content
Estimación de tiempo

Define Multiple Paths in a Flow

Learning Objectives

After completing this unit, you’ll be able to:

  • Interpret business requirements and visualize them in a process flowchart.
  • Build a flow to implement the business requirements process.
  • Use branching logic to select one of multiple paths in a flow.
Note

This badge is one stop along the way to Flow Builder proficiency. From start to finish, the Build Flows with Flow Builder trail guides you through learning all about Flow Builder. Follow this recommended sequence of badges to build strong process automation skills and become a Flow Builder expert.

Before You Start

This badge assumes that you know how to create a flow with variables, inputs, and data elements, such as Get Records. If you aren’t familiar with these concepts or need a refresher, see the Flow Builder Basics badge and the Data and Actions in Flows badge.

When your flow runs, it travels like a train, moving down the path toward the end and making things happen at each stop. But trains don’t always travel down a single path. Train tracks split, converge, and loop to get where they need to go. Flow Builder allows you to build automation that does the same thing, with paths that branch and merge as you see fit.

Flo Smith driving a steam train engine down a track that goes in multiple directions

The Power of If

Some automation use cases require you to automate in different ways for different situations. Let’s take a look at an example.

Flo Smith is a senior Salesforce admin and business analyst for Pyroclastic, Inc. In this module, you’re a Salesforce admin on Flo’s team, helping her automate some of Pyroclastic’s business processes. 

Flo’s task for you today is to build automation that automatically sets the right priority when support cases are created. The priority value depends on the type of issue and the influence of the requester. Flo starts by reviewing the business requirements.

  1. If Type = Downtime: priority = Severity 0.
  2. If Type = Usability and the contact who submitted it is a VIP: priority = Severity 1.
  3. If Type = Usability and the contact who submitted it is not a VIP: priority = Severity 2.
  4. Otherwise (else), priority = Severity 3.

Notice that all of the lines except the last one start with if. The last line acts as a default for cases that meet none of the preceding three requirements.

Note

By organizing the lines this way, Flo has created what developers call an if-then-elseif statement. IF something is true, THEN take action; ELSE, check IF another thing is true. That if holds a lot of flow-er power!

Next, you and Flo create a flowchart diagram to visualize the automation that will set case priority. You can do this in whatever way works for you: anything from sketching on paper to using a design tool or flowchart program. Your goal is to transform the requirements from text into a visual model of your intended automation.

Let’s examine the flowchart diagram. It has four business requirements.

A flowchart corresponding to the preceding requirements. The layout has 3 questions (diamonds) and 4 results representing Severity 0 - Severity 3.

Each business requirement includes a Severity box for the path to select when the requirement is met, the Yes path. In Flow Builder, those are called outcomes, and each outcome has its own path on the canvas.

Each outcome (except the last one) has conditions that must be met. In Flow Builder, those are called condition requirements.

Decision element flowchart with four outcomes and three diamonds, corresponding to requirements 0, 1, 2, and 3 defined previously.

The last outcome is the default. It has no conditions. The flow chooses the default outcome when none of the other outcomes’ conditions are met.

To create this sort of branching logic in a flow, you use a Decision element.

The Decision Element

The Decision element lets you create multiple paths. Building a Decision element based on a flowchart diagram has two steps.

  1. Create one outcome for each Yes path in the diagram. (The final No path is handled by the default outcome.) Outcomes are listed in order under Outcome Order.
  2. Add condition requirements to each outcome except the default outcome. The condition requirements for each outcome come from its corresponding diamond in the flowchart.

The Decision element includes outcomes and condition requirements corresponding to the preceding steps.

The Decision element’s paths represent the outcomes.

The Flow Builder canvas, showing a Decision element that splits into four paths representing Severity 0 to Severity 3.

When the flow reaches a decision element, it evaluates the first Outcome. If its conditions are met, the flow chooses that outcome and follows its path. If not, the flow continues through the Outcome Order until it finds an outcome for which the condition requirements are met. If none of the outcomes’ condition requirements are met, the flow follows the default outcome’s path. When the separate paths merge, the flow returns to that single path.

Ready to Get Hands-on with Flow Builder?

Launch your Trailhead Playground now to follow along and try out the steps in this module. To open your Trailhead Playground, scroll down to the hands-on challenge and click Launch. You also use the playground when it's time to complete the hands-on challenges.

Build a Decision Element

Let’s create a flow to automate this business process. But first, add these required picklist values to the relevant fields. For more info on adding picklist values, see the Manage Your Picklist Values unit in the Picklist Administration badge.

  1. On the Case object, in the Priority field, add these values: Severity 0, Severity 1, Severity 2, Severity 3
  2. On the Case object, in the Type field, add these values: Downtime, Usability

Create a Decision Element and Define Outcomes

Follow these steps to recreate the flowchart process as a flow, using a Decision element.

  1. Create a record-triggered flow:
    • For Object, select Case.
    • Accept the default trigger configuration and entry conditions.
    • Under Optimize the Flow for, select Fast Field Updates.
      Choose Fast Field Updates when all you want to do is update the triggering record. Check out the Record-Triggered Flows badge for more info on Fast Field Updates.
  1. Add a Decision element to the flow:
    • On the canvas, click Add Element.
    • Select Decision.
    • For Label, enter Check Case Details.
  1. Define the outcomes:
    • Under OUTCOME ORDER, leave New Outcome selected.
    • Under OUTCOME DETAILS, for Label, enter Severity 0.
    • Next to OUTCOME ORDER, click New Outcome to create a new outcome.
    • Label the second outcome Severity 1.
    • Create another outcome and label it Severity 2.
    • Under OUTCOME ORDER, select Default Outcome.
    • Change its label to Severity 3 (Default).

Add Condition Requirements to the Outcomes

  1. Define the condition requirements for the Severity 0 outcome:
    • Under OUTCOME ORDER, select Severity 0.
    • Under OUTCOME DETAILS, for Resource, click Triggering Case and select Case Type.
    • Keep Equals as the Operator.
    • For Value, select Downtime.
  1. Define the condition requirements for the Severity 1 outcome:
    • Enter the first condition requirement:
      • Resource: Triggering Case > Case Type
      • Operator: Equals
      • Value: Usability
    • Click Add Condition.
    • Enter the second condition requirement:
      • Resource: Triggering Case > Contact ID > Contact Description
      • Operator: Contains
      • Value: VIP
  1. Define the condition requirements for the Severity 2 outcome:
    • Resource: Triggering Case > Case Type
    • Operator: Equals
    • Value: Usability
      Even though the third diamond in our diagram specifies that the contact is not a VIP, we don’t need to check that requirement for Severity 2. Condition requirements are evaluated in order, so the Decision element doesn't check this outcome unless the contact isn't a VIP.

Your decision element should now look like this:The Decision side panel with four outcomes corresponding to the requirements: Severity 0, 1, 2, and 3.

Click Close to close the side panel.

Your flowchart had four potential outcomes, so the Decision element has four outcomes. Those four outcomes create four possible paths the flow can take, each named for its corresponding outcome. Here’s what it looks like on the canvas.

The Flow Builder canvas, showing a Decision element with 4 paths corresponding to the previously defined outcomes: Severity 0, Severity 1, Severity 2, and Severity 3.

Now’s a good time to save and name your new flow.

  1. Click Save.
  2. For Flow Label, enter Set Case Priority.
  3. Click Save.

Create Update Records Elements

On each severity path, you add an element that updates the new case with the appropriate priority value. For example, in the Severity 0 path, you set the Priority field to Severity 0.

First, add an Update Records element to the first three paths.

  1. Under Severity 0, click Add Element.
  2. Under Shortcuts, select Update Triggering Record.
  3. For Label, enter Set Priority to Sev0.
  4. Accept the autogenerated API Name.
  5. Under How to Find Records to Update and Set Their Values, keep the default value: Use the case record that triggered the flow.
  6. Scroll to Set Field Values for the Case Record.
  7. For Field, select Priority.
  8. For Value, select Severity 0.
  9. Click Close in the Update Records panel to close the panel.
  10. Repeat steps 1-9 for the Severity 1 and Severity 2 paths. Don’t forget to change the Label and Value for each path.

For the Severity 3 path, you copy and paste the element from the Severity 2 path. (This is a pretty simple example, but if you ever need to copy or move (cut and paste) a whole bunch of elements together, this is a good technique to know.)

  1. Click the Set Priority to Sev2 element.
  2. Click Copy Element.
  3. Under Severity 3, click Add Element.
  4. Click Paste 1 Element.
  5. Click the new element and select Edit Element.
  6. Change the Label to Set Priority to Sev3.
  7. Change the API Name to Set_Priority_to_Sev3
  8. Change the field Value to Severity 3.
  9. Save the flow.

Your flow should look like this on the canvas.

The Flow Builder canvas, showing the same Decision element with 4 paths, and each path now including a separate Update Records element. Each Update Records element is labeled with the value to which it sets the Priority.

When the flow follows the path for a specific outcome, it runs only the Update Records element in that path.

Note

To see your flow in action, click Activate to activate the flow, and then create a case. Only users with the Manage Flows permission can run a flow that isn’t activated. Be aware that when a flow is activated, you can’t make changes to that version of the flow. Instead, create a new version of the flow and make your changes in that new version.

Resources

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios