Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.
Estimación de tiempo

Build a Record-Triggered Flow

Learning Objectives

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

  • Define the key components used to create a record-triggered process.
  • Describe when to use Fast Field Updates.
  • Describe when to use Actions and Related Records.
  • Identify options for when to run a flow when a record is updated.
  • Build a flow that creates a draft contract based on a change in the opportunity.

Business Requirement

What do you want your record-triggered flow to do? Suppose you want to automatically create contracts for Closed Won high-value opportunities. That’s your business requirement. 

To build a record-triggered flow, we define the business requirement in three parts: trigger, criteria, and action. For example: If an opportunity is created or updated (trigger) and it’s high-value and closed won (criteria), then create a draft contract (action). 

The business requirement corresponding to the preceding description

Plan and Explain Your Flow

Make things easier on yourself by planning your record-triggered flow before you try to build it. Consider these questions.

  • Does the flow run immediately or is it scheduled?
  • Does the flow create another record or just update a record?
  • Does the flow run every time a record is updated or only the first time its criteria are met?

Sketch your business processes before building them in Flow Builder. Use the Description fields in your flow to explain your intent and design. Those descriptions will be helpful later for you and anyone else who updates the flow.

Configure Start

This is where you select an object, configure the trigger, and set entry conditions.

  1. From Setup, enter Flows in the Quick Find box, then select Flows.
  2. Click New Flow.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Record-Triggered Flow.
  5. Click Create.

Define the Trigger

The Start element's configuration panel corresponding to the steps that follow.

  1. For Object, select Opportunity.
  2. For Trigger the Flow When, select A record is created or updated.
    The conditions (the criteria that trigger the flow) are checked every time a record is updated, ensuring that no changes are missed.
  3. For Condition Requirements, select All Conditions Are Met (AND).
  4. Define the first condition:
    • Field: StageName
    • Operator: Equals
    • Value: ClosedWon
  1. Click Add Condition.
  2. Define the second condition:
    • Field: Amount
    • Operator: Greater Than
    • Value: 25000
  1. For When to Run the Flow for Updated Records, select Only when a record is updated to meet the condition requirements.
    Why did we select this option? We want the Flow to run only when the triggered record is changed from not meeting the entry conditions to meeting the entry conditions. The trigger fires every time an opportunity is edited, but we want to create a contract only once. If we don’t select ‘Only when a record is updated to meet the condition requirements’, then every time the description (or anything else) in a ClosedWon opportunity for an amount greater than 25000 is edited, the flow will run and create another contract.
  2. For Optimize the Flow For, select Actions and Related Records.
    With this option you can update any record (not just the record that triggered the flow) and perform actions.

The resulting Start element displays these settings.

  • Object: Opportunity
  • Trigger: A record is created or updated
  • Conditions: 2
  • Optimize for: Actions and Related Records

Graphic representation of the preceding flow details

Note

If you’re trying to update the record that triggered the flow, then you should optimize the flow using Fast Field Updates. A flow using Fast Field Updates runs before the record is saved to the database.

Create a New Record

Now let’s create a Salesforce record using values from the flow.

  1. On the flow canvas, on the path after the Start element, click Add Element.
  2. Scroll to the Data section and click Create Records. The New Create Records window opens.
    New Create Records screen. Fields include Label, API Name, Description, How Many Records to Create, and How to Set the Record Fields.
  3. For Label, enter Create Draft Contract. The API Name is automatically updated to Create_Draft_Contract.
  4. For Description, enter Create a draft contract when an opportunity is won and is over 25,000.
  5. For How to set record field values, select Manually.
    Use this option to populate the new contract record with data we choose from multiple sources. With From a Record Variable, you must first create a record variable and set its values. It's easier and more efficient to manually select the values you want to use in the new record.
  6. For Object, select Contract.
  7. Under Set Field Values for the Contract, associate the new contract with the opportunity’s account:
    • Field: Account ID
    • Value: Triggering Opportunity > Account ID (select the Account ID that doesn’t have a > at the end of the line)
      Data from the record that triggered the flow is stored in the Triggering variable. To insert values from the triggering opportunity, start with Triggering Opportunity and drill down. In this example, we set the account on the new contract record to match the account related to the opportunity.
  1. Click Add Field.
  2. Set the Status of the new contract:
    • Field: Status
    • Value: Draft

Save and Debug

It’s a best practice to save your flow often, and debug it immediately after completing it. Debugging your flow before activating it lets you try different scenarios without impacting your data.

  1. Click Save.
  2. For Flow Label, enter Closed Won Opportunities. The Flow API Name field is automatically updated to Closed_Won_Opportunities.
  3. For Description, enter If a high-value opportunity is closed and won, create a draft contract.
  4. Click Save.
  5. Click Debug.
    Debug flow screen. Fields include Select Path, Debug Options, and Run the Flow As if the Record is Created or Updated.
    If there were multiple paths, we could only debug one path at a time.
  6. Under Debug Options, select Skip start condition requirements.
  7. For Run the Flow As If the Record Is, select Updated.
  8. For Opportunity, find and select an opportunity to run the flow against. This example uses Grand Hotels Emergency Generators. Make sure the Opportunity you select is Closed Won and its Amount is over 25000.
  9. In the opportunity, scroll down and verify that the amount is larger than 25000. If it’s not, enter an amount larger than 25000.
  10. Click Run. The flow is debugged. If it ran successfully, the line connecting elements is dark blue.
    The Debug screen displays the flow diagram, debugging details, and Completed status.
  11. Click Expand All to view more information in the Debug Details panel.
  12. Click Back (“”) to exit Flow Builder.

Well done! You built a record-triggered flow.

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