Get Started with Custom Metadata Types
- Define custom metadata types.
- Identify several use cases for custom metadata types.
Do you hear your developer talking about app configuration records and wonder what they are? Or, maybe you know what they are and need to migrate app configuration records between Salesforce orgs, but you’re not a developer. In this module, we give you the skinny on app configuration records and how Custom Metadata Types can help you—even if you’re not a developer.
Instead of storing data, app configuration records customize your app’s behavior. For example, if you create a workflow rule, you essentially create a Salesforce record that tells your app how to behave.
- Creating configuration records in one or more development orgs.
- Sending the configuration records through integration and user acceptance testing.
- Deploying the records to at least one production org.
Custom metadata is customizable, deployable, packageable, and upgradeable application metadata. First, you create a custom metadata type, which defines the form of the application metadata. Then you build reusable functionality that determines the behavior based on metadata of that type. You use records to configure your app instead of settings. You can customize, deploy, package, and upgrade application metadata that you design. And you can do much of this work using declarative functionality.
Use Custom Metadata Types
Mappings—You can use custom metadata types to create associations between different objects. For example, you can create a custom metadata type that assigns cities, states, or provinces to particular regions in a country.
Business rules—Salesforce has lots of ways to define business rules. One way is to combine configuration records with custom functionality. For example, you can use custom metadata types along with some Apex code to route payments to the correct endpoint.
Master data—Say that your org uses a standard accounting app. You can create a custom metadata type that defines custom charges, like duties and VAT rates. If you include this type as part of an extension package, subscriber orgs can reference this master data.
More About Custom Metadata Types
- Metadata Relationship
- Date and Date/Time
- Email and Phone
- Text and Text Area
Let’s create two custom fields on our type: A Minimum Spending field of type Number and 2 decimal places, and a Default Discount field of type Percent. Minimum Spending will determine how much a particular account needs to spend in order to qualify for a support tier. Default Discount is the automatic discount applied to a specific tier.
After you create the type with all its fields, create custom metadata records that are defined by that type. These records store the actual configuration data. For our example, you create a record for each support tier that’s relevant to your org.
|Label||Minimum Spending (Custom Field)||Default Discount (Custom Field)|
Later, you can package and install all of these components, including your records, in other orgs. To include more support tiers later, you can add the new records to your package.
Let’s stop reading, though, and create our own custom metadata type in the next unit.