Skip to main content

Use Automation Components in Flow Builder

Follow Along with Trail Together

Want to follow along with an expert as you work through this step? Take a look at this video, part of the Trail Together series.

(This clip starts at the 7:03 minute mark, in case you want to rewind and watch the beginning of the step again.)

Introduction

Ready to put your skills to the test and implement an automation component? Let’s build a flow that puts into practice what you've learned and set up so far.

Build a Flow to Lock Closed Lost Opportunities

The Universal Containers team wants to lock opportunities that have been set to Closed Lost so users don’t modify the opportunities. To achieve this, they can use a Record-Triggered Flow to evaluate changes on an opportunity. If the Opportunity Stage has been set to Closed Lost, they can use the Record Lock invocable action from the Automation Components Sample Application to lock the record.

Enable Record Locking in Apex

  1. In your Trailhead Playground, from Setup, enter Process Automation Settings in the Quick Find box and select Process Automation Settings.
  2. In Default Workflow User, click the lookup icon and select your name.
  3. Select Enable record locking and unlocking in Apex.
  4. Click Save.

Create a Flow

  1. From Setup, enter Flows in the Quick Find box and select Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.

Set the Trigger Criteria

Select the event (trigger) and object that cause the flow to run.. 

  1. Search for the Opportunity object and select it.
  2. Change the Trigger the Flow When selection to A record is updated.
  3. Select Done.
  4. Click the Auto-Layout button and select Freeform.

Filter with a Decision Element

Filter out opportunities that have not been Closed Lost in the flow so that we only update the correct records. 

  1. From the Elements tab in the toolbox, drag Decision onto the canvas.
  2. In the New Decision window, enter these values.
    1. Label: Opportunity Closed Lost?
    2. API Name: Opportunity_Closed_Lost
  3. Make sure that New Outcome is selected, and enter these values into the Outcome Details section.
    1. Label: Closed Lost
    2. API Name: Closed_Lost
    3. Select All Conditions Are Met (AND).
  4. For Resource, enter these conditions.
    1. Resource: {!$Record.StageName}
    2. Operator: Equals
    3. Value: Closed Lost
  5. For When to Execute Outcome, select  If the condition requirements are met.
  6. Select Done.

Add the Action

Use the Lock Record action from the Automation Components Sample Application inside the Flow Builder.

  1. From the toolbox, drag the Action element onto the canvas.
  2. Select the Security category.
  3. Click in the search box.
  4. Select Locks or unlocks a record.
    1. Flow Label: Lock Record
    2. Flow API Name: Lock_Record
  5. For recordId, select the {!$Record.Id} field from the opportunity.
  6. Under Set Input Values, for isLocked:
    1. Move the Don’t Include slider to Include.
    2. Select or enter $GlobalConstant.True
  7. Select Done.

Connect the Elements to Finish the Flow

Connecting the flow elements tells the flow what order to follow at runtime.

  1. At the bottom of Start, select the node and drag it to the Opportunity Closed Lost? Decision.
  2. At the bottom of the Opportunity Closed Lost? Decision, select the node and drag it to the Lock Record Action.
    1. For the outcome, select Closed Lost.
    2. Select Done.
  3. Click Save.
    1. Label: Lock Opportunity Record
    2. API Name: Lock_Opportunity_Record
  4. Click Save.
  5. Click Activate.
  6. Click Back.

Flow Navigation Bar

Update an Opportunity

Let’s check that our flow is running by updating an Opportunity Stage to Closed Lost.

  1. Open the App Launcher and select the Sales app.
  2. In the search bar, type University of AZ Installations and select it.
  3. Select Closed in the opportunity path and select Select Closed Stage.
    1. Update the Stage to Closed Lost.
    2. Click Save.
  4. The opportunity is now locked. As an admin, you are still able to edit the record, but your users are no longer able to edit.

What’s Next?

While this is the end of your introduction to the Automation Components app, there’s more to explore. Feel free to take a look at the other components and get hands on with them in Flow Builder. 

You can also check out the other sample apps in the Trailhead Sample Gallery. Here, you can complete projects, explore source code, and continue to grow your skills.

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities