Difference between custom setting and custom metadata Salesforce

In this post, we will talk about the difference between custom settings and custom metadata Types in Salesforce. Before to that let understand what is custom settings and Custom Metadata Type in Salesforce.

What is Custom Setting?

Custom Settings are like custom objects. They are generally used to create custom sets of data and can be associated with an organization, profile or a specific user. The visibility of the custom setting can be controlled by marking it as public or protected. Custom Settings data set can be used in Formula fields, Validation rules, flows, Apex and SOAP API.

What is Custom Metadata Types?

The term “Metadata” is nothing but data about data. In simple words, when you are creating a record within Salesforce, you are creating data as well as metadata. The data which you are trying to enter, is captured or stored in the fields which are nothing but columns of your Object. 

Custom Metadata Types in Salesforce are similar to custom objects. It has a suffix of “__mdt” instead of “__c” in the API namespace.

Differences between Custom Metadata Types and Custom Settings

We know the primary difference between custom metadata type and custom setting is that custom metadata type records are deployable but we can not deploy custom setting data. But there are lots of other difference. Let have a look.

Custom SettingsCustom Metadata Types
TypeCustom Settings are also similar to custom objects. You can either create a List based or hierarchy based custom setting.Custom metadata does not support Hierarchy type of data based on user profile or a specific user.
DeploymentCustom settings data cannot be deployed using packages or Metadata API/Change Sets.Custom metadata types data can be easily packaged and deployed. Metadata types can also be deployed via Change Sets/Metadata API.
Relationship FieldCustom settings do not support relationship fields.You can create lookups between Custom Metadata objects.
SuffixIt has a suffix of “__C” like custom object It has a suffix of “__mdt”
Test ClassCustom setting data is not visible in test classes.Custom metadata types are visible in test class without the “SeeAllData” annotation.
DML in ApexYou can perform CUD (Create, Update, Delete) operation on custom setting in apex.You cannot perform CUD (Create, Update, Delete) operation on custom metadata type in apex.
SOQLYou can access custom setting data using instance methods and can avoid SOQL queries to databaseWith custom metadata types, you can issue unlimited (SOQL) queries for each Apex transaction. But method is also available.

Summary

We recommend use custom setting for hierarchy based data and use Custom Metadata Types for list base data.

Amit Chaudhary
Amit Chaudhary

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.

He is a active blogger and founder of Apex Hours.

Articles: 460

Leave a Reply

Your email address will not be published. Required fields are marked *