進行状況の追跡を始めよう
Trailhead のホーム
Trailhead のホーム

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.

Overview

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, in Quick Find type Flows, select Flows, and then click New Flow.
  2. Select Screen Flow, then click Create.
  3. From Toolbox Elements, drag Get Records onto your palette and enter Get Support Tier Config for the label.
    We need to reference the Support Tier records to help us update accounts where minimum spending has reached Gold status.
  4. Click in the API Name field to insert the name Get_Support_Tier_Config.
  5. For Object, select Support Tier.
  6. For Filter Support Tier Records, select Get All Support Tier Records (No Conditions).
  7. Scroll down and select Manually assign variables (advanced).
  8. Click in the Select Variable to Store Support Tier field, then click New Resource.
    1. For Resource Type, select Variable.
    2. For API Name, enter Support_Tier_Var.
    3. For Data Type, select Record.
    4. For Object, select Support Tier.
    5. Select both Available for input and Available for output and then click Done.
  9. Under Select Support Tier Fields to Store in Variable, enter the field values.
    1. For Field, select Default_Discount__c.
    2. Add a field for each of the following: DeveloperName, Label, and Minimum_Spending__c.
  10. Click Done.
  11. Drag Update Records onto the flow palette and for Label, enter Update Gold Accounts.
    Based on the configuration records that we just got, we want to update some accounts.
  12. Select Specify conditions to identify records, and set fields individually:
    1. For Object, select Account.
    2. For Condition Requirements, select Conditions are Met.
    3. For Field, select Total_Spending__c.
    4. For Operator, select Greater Than or Equal.
    5. For Value, enter {!Support_Tier_Var.Minimum_Spending__c}.
  13. Under Set Field Values for the Account Records:
    1. For Field, select Support_Tier__c.
    2. For Value, select Gold.
  14. Click Done.
  15. Connect the flow elements.
  16. Click Save.
  17. Enter a Flow Label and Flow API Name, and click Save.
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.

Resources