Custom Metadata Types salesforce

Custom Metadata Types salesforce

What are Custom Metadata Types?

Custom metadata type in salesforce is customizable, deployable, packageable, and upgradeable application metadata. Custom metadata types are mainly used for app configuration. Custom Metadata Types are similar to Custom Settings in Salesforce, except that they are deployable and packagable. 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.

Custom Metadata Types salesforce

 

After you create a public custom metadata type, you or others can declaratively create custom metadata records that are defined by that type. When you package a public custom metadata type, customers who install the package can add their own records to the metadata type. Your reusable functionality reads your custom metadata and uses it to produce customized application behavior. For example, you can use custom metadata types for the following.

  • Mappings—Create associations between different objects, such as a custom metadata type that assigns cities, states, or provinces to particular regions in a country.
  • Business rules—Combine configuration records with custom functionality. Use custom metadata types along with some Apex code to route payments to the correct endpoint.
  • Master data—Let’s say that your org uses a standard accounting app. 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 the master data.
  • Whitelists—Manage lists, such as approved donors and pre-approved vendors.
  • Secrets—Store information, like API keys, in your protected custom metadata types within a package.

Custom metadata rows resemble custom object rows in structure. You create, edit, and delete custom metadata rows in Metadata API or in Setup. Because the records are metadata, you can migrate them using packages or Metadata API tools.

Difference Between Custom Settings and Custom Metadata Types

Main difference between custom metadata and custom setting is that custom metadata records are deployable and packagable. But we can not deploy custom setting data.

Here is list of Difference Between Custom Settings and Custom Metadata Types

  • Custom settings enable you to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. Custom metadata are like custom setting but records in custom metadata type considered as metadata rather than data. These are typically used to define application configurations that need to be migrated from one environment to another, or packaged and installed.
  • There are 2 types of custom setting List and Hierarchy Custom setting. There are no such types in custom metadata. Custom metadata does not support Hierarchy type of data based on user profile or specific user.
  • You can control the visibility of custom setting by specifying it as public or protected. If custom setting is marked as protected, the subscriber organization will not be able to access the custom setting. If it is marked as public, then subscriber org can also access it.  You can control the visibility of Custom Metadata Types by specifying it as public or protected. If it is marked as public type, then anyone can see it. If it is marked as protected type, in the installed managed package subscriber organization, only Apex code in that managed package can use it.
  • Custom settings do not support relationship fields. You can create lookups between Custom Metadata objects.
  • You can access custom setting data using instance methods and can avoid SOQL queries to database. With custom metadata types, you can issue unlimited Salesforce Object Query Language (SOQL) queries for each Apex transaction.
  • Custom metadata type are visible in test class without “SeeAllData” annotation but custom setting data is not visible.
  • Custom metadata records are deployable but custom setting data is not.

 

For more details refer to official link and custom metadata type trailhead

Permanent link to this article: https://www.sfdcpoint.com/salesforce/custom-metadata-types-salesforce/

1 ping

    1. […] Main difference between custom metadata and custom setting is that custom metadata records are deployable and packagable. But we can not deploy custom setting data. Custom settings enable you to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. via […]

    Leave a Reply

    Your email address will not be published.