進行状況の追跡を始めよう
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

Let’s create our flow:

  1. From Setup, in Quick Find type Flow, select Flows, and then click New Flow.
    We’re going to add elements to get records and update records.
  2. From Elements, drag Get Records onto your palette and enter Get Support Tier Config for the label. We need to reference Support Tier records to help us update accounts where minimum spending has reached Gold status.
  3. For Object, select Support Tier.
  4. Scroll to Select Variable to Store Support Tier and 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.
  5. Scroll down to Select Variable to Store Support Tier again and select the variable that you created.
  6. Under Select Support Tier Fields to Store in Variable, select:
    1. Default_Discount__c
    2. Add a field and select DeveloperName, Label, Minimum_Spending__c
  7. Click Done.
  8. Drag Update Records onto the palette and for Label, enter Update Gold Accounts.
    Based on the configuration records that we just got, we want to update some accounts.
  9. 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, select {!Support_Tier_Var.Minimum_Spending__c}.
  10. Under Set Field Values for the Account Records:
    1. For Field, select Support_Tier__c.
    2. For Value, select Gold.
  11. Connect the elements and save your work as a screen flow.
An image of the flow created in steps 1-11.
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 Flow Builder.

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

retargeting