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
- In your Trailhead Playground, from Setup, enter
Process Automation Settings
in the Quick Find box and select Process Automation Settings.
- In Default Workflow User, click the lookup icon and select your name.
- Select Enable record locking and unlocking in Apex.
- Click Save.
Create a Flow
- From Setup, enter
Flows
in the Quick Find box and select Flows.
- Click New Flow.
- Make sure Start from Scratch is selected, and click Next.
- Select Record-Triggered Flow and click Create.
Set the Trigger Criteria
Select the event (trigger) and object that cause the flow to run..
- Search for the Opportunity object and select it.
- Change the Trigger the Flow When selection to A record is updated.
- In the button bar, change the Auto-Layout setting to Free-Form.
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.
- From the Elements tab in the toolbox, drag Decision onto the canvas.
- In the New Decision window, enter these values.
- Label:
Opportunity Closed Lost?
- API Name:
Opportunity_Closed_Lost
- Make sure that New Outcome is selected, and enter these values into the Outcome Details section.
- Label:
Closed Lost
- API Name:
Closed_Lost
- Select All Conditions Are Met (AND).
- For Resource, enter these conditions.
- Resource: select Triggering Opportunity, then select Stage
- Operator: Equals
- Value: Closed Lost
- For When to Execute Outcome, select If the condition requirements are met.
- Click Done.
Add the Action
Use the Lock Record action from the Automation Components Sample Application inside the Flow Builder.
- From the toolbox, drag the Action element onto the canvas.
- Select the Security category.
- Click in the search box.
- Select Locks or unlocks a record.
- Flow Label:
Lock Record
- Flow API Name:
Lock_Record
- For recordId, select Triggering Opportunity, then select Opportunity ID.
- Under Set Input Values, for isLocked:
- Move the Don’t Include slider to Include.
- Select True
- Click Done.
Connect the Elements to Finish the Flow
Connecting the flow elements tells the flow what order to follow at runtime.
- At the bottom of Start, select the node and drag it to the Opportunity Closed Lost? Decision.
- At the bottom of the Opportunity Closed Lost? Decision, select the node and drag it to the Lock Record Action.
- For the outcome, select Closed Lost.
- Select Done.
- Click Save.
- Label:
Lock Opportunity Record
- API Name:
Lock_Opportunity_Record
- Click Save.
- Click Activate.
- Click Back.
Update an Opportunity
Let’s check that our flow is running by updating an Opportunity Stage to Closed Lost.
- Open the App Launcher and select the Sales app.
- In the search bar, type
University of AZ Installations
and select it.
- Select Closed in the opportunity path and select Select Closed Stage.
- Update the Stage to Closed Lost.
- Click Save.
- 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.