Skip to main content
TrailblazerDX, the ultimate AI learning event is heading back to San Francisco March 6-7, 2024. Register Now and save 35% with code T24DEYE424.

Use Custom Metadata Types in Flows

Learning Objectives

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

  • Explain how to reference a custom metadata type record in a flow.
  • Use Flow Builder to reference a custom metadata type and include its record information in a flow.

Overview

Good progress so far! Let’s keep the momentum going, because we can do even more with custom metadata types. 

Before we continue, though, make sure that you’ve checked out how to use Salesforce Flow tools in Trailhead. We’re going to reference a custom metadata type record in a flow. Still learning the ins and outs of using Flow Builder? Our example here is super simple, so don’t fear. When you see how you can use custom metadata types in Flow Builder, you’ll want to build your own flow.

You probably already know that Flow Builder is a tool that you can use to automate business processes. Acme Services is a large, multinational service company, so creating repeatable business flows is crucial to functioning efficiently.

Acme Services wants to automatically update the support tier associated with an account when the account reaches a required spending threshold. Because Acme Services imports a lot of data from external systems, they need to automate this process using flows that run on a schedule.

Create a Flow That References a Custom Metadata Type Record

In the Create and Manage Custom Metadata Types unit, you created a custom metadata type called Support Tier. This unit references that custom metadata type and record for a flow.

Let’s create our flow. In this step, you specify that a change to the Account Total Spending field triggers an update to the account's Support Tier. The Total Spending field is updated when you change the Amount in a related opportunity.

  1. From Setup, enter Flows in the Quick Find box, then select Flows.
  2. Click New Flow, select Record-Triggered Flow, and click Create.
  3. For Object, select Account. 
  4. For Configure Trigger, select A record is created or updated. 
  5. For Set Entry Conditions, select All Conditions Are Met (AND) and enter these values.

    Field  Operator  Value 
    Total_Spending__c Is Changed {!$GlobalConstant.True}
  6. For Optimize the Flow for, select Fast Field Updates.

Get the Support Tier Data

  1. On the flow canvas, on the path after the Record-Triggered Flow element, hover over Add Element and click Add Element. Select Get Records.
  2. For the label, enter Get Support Tier Config.
    We need to reference the Support Tier records to help us update accounts where minimum spending has reached Gold status.
  3. The API Name is automatically set to Get_Support_Tier_Config.
  4. For Object, select Support Tier.
  5. For Filter Support Tier Records, select All Conditions Are Met (AND) and enter these values.

Field 

Operator 

Value 

MasterLabel

Equals

Gold

You’ve successfully configured the conditions that trigger the flow, identified the Support Tier object, filtered the object’s records, and set the sort for the filtered records. Next, you update the Account record.

Update the Account Record

In an Update Records element, you identify which records to update and how you want to update those records. We want to update the Account record that triggered the flow.

  1. On the path after the Get Support Tier Config element, hover over Add Element and click Add Element. Select Update Records.
  2. For Label, enter Update Gold Account.
  3. The API Name is automatically set to Update_Gold_Account.
  4. Click Use the account record that triggered the flow.
  5. For Filter Account Records, select All Conditions Are Met (AND) and enter these values.
    Field  Operator  Value 
    Total_Spending__c Greater Than or Equal {!Get_Support_Tier_Config.Minimum_Spending__c}
  6. In the Set Field Values for the Account Records section, add the field values.

    Field  Value 
    Support_Tier__c Gold

Save and Activate the Flow

  1. Click Save.
  2. Enter a Flow Label and Flow API Name.
  3. Click Save.
  4. Click Activate.
    Any previously activated version (if one exists) is deactivated.

Check the Flow

We want to make sure that the flow will update the record, so before running the flow, let's confirm the current Support Tier value and change the opportunity amount.   

  1. From the App Launcher (The App Launcher icon.), select Sales and click on the Accounts tab.
  2. Open the Beebs Publishing account and click the Details tab.
  3. Confirm that the Support Tier is Bronze.
  4. Click the Related tab.
  5. From Beebs Publishing Q1 opportunity, select Edit.
  6. Change Amount to 5,500 and click Save.
  7. Open the Beebs Publishing account and refresh the page.
    The Support Tier should now be Gold.

Since the account’s minimum value meets or exceeds the minimum in the Gold Support Tier, the record is updated to the Gold tier. And that’s it. You just created a flow that references custom metadata type records.

Let’s recap what we’ve done in this module, which is a lot given that we didn’t need to code anything.

  • We created a custom metadata type and added records to it.
  • We referenced a custom metadata type record in a formula and also in a default value.
  • We created a validation rule based on a custom metadata type record.
  • We used records from a custom metadata type in a flow.

If you continue to the next module, and we hope you do, you can learn about some of the more technical aspects of working with custom metadata types.

Resources

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