Start tracking your progress
Trailhead Home
Trailhead Home

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 flow.


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

Before we continue, though, make sure that you’ve checked out how to use Lightning 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:

  1. From Setup, enter Flows in the Quick Find box, then select Flows.
  2. Click New Flow, select Screen Flow, and click Create.
  3. From the Elements tab in the toolbox, drag Get Records onto the canvas.
  4. 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.
  5. The API Name is automatically set to Get_Support_Tier_Config.
  6. For Object, select Support Tier.
  7. For Filter Support Tier Records, select Conditions are Met and enter these values.
    Field Operator Value
    MasterLabel Equals Gold
  8. Set the Sort Order to Ascending and Sort By to DeveloperName.
  9. Click Done.

    You’ve successfully identified the Support Tier object, filtered the object’s records, and set the sort for the filtered records. Next, you’ll update those records.

Update the Account Records

In an Update Records element, you identify which records to update and how you want to update those records. Based on the configuration records that we got, we want to update some accounts.

  1. From the Elements tab in the toolbox, drag Update Records onto the canvas.
  2. For Label, enter Update Gold Accounts.
  3. The API Name is automatically set to Update_Gold_Accounts.
  4. Click Specify conditions to identify records, and set fields individually.
  5. For Object, select Account.
  6. For Filter Account Records, select Conditions are Met and enter these values.
    Field Operator Value
    Total_Spending__c Greater Than or Equal {!Get_Support_Tier_Config.Minimum_Spending__c}
  7. In the Set Fields Values for the Account Records section, add the field values.
    Field Value
    Support_Tier__c Gold
  8. Click Done.

Connect and Run the Flow

The last step is connecting and running the flow.

  1. Connect the flow elements.
  2. Click Save.
  3. Enter a Flow Label and Flow API Name.
  4. Click Save and run the flow.
    The account records with a minimum value that meets or exceeds the minimum in the Gold Support Tier record are 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.
  1. We created a custom metadata type and added records to it.
  2. We referenced a custom metadata type record in a formula and also in a default value.
  3. We created a validation rule based on a custom metadata type record.
  4. 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.