Home SalesforceInterview Question Custom Setting and Custom Metadata Type

Custom Setting and Custom Metadata Type

by Dhanik Lal Sahni

Custom Setting and Custom Metadata Type are used to store application secrets. We can use both of them to store the application’s configuration data. Although both are used to store configuration data but both have different use cases.

Similarity of Custom Metadata Types and Custom Setting

  1. Both Custom Setting and Metadata type avoid Governor Limits. If we use SOQL to get custom settings then the Governer limit will be enforced. If we will use the custom setting method to query then it will bypass the governer limit
  2. Both can be used to store encrypted data.
  3. Both are internally cached so it will help us in better-performing applications.
  4. Both can be used in the formula field.
  5. We can not create tabs for both

Difference between Custom Metadata Types and Custom Setting

Sr#Custom SettingCustom Metadata Type
1.Only metadata of Custom Setting is deployable. We have to create a configuration record post-deployment.Custom Metadata Types are deployable. We can deploy all configuration records to any org. These are also created using Org refresh.
2.Custom Setting support hierarchy so that we can create different data based on user and profileCustom metadata types do not support data for profile/user/permission sets directly but we can control visibility using Enhanced Profile User Interface
3.Custom setting records’ values can be edited in codeCustom metadata cannot be edited in code. Custom Metadata is metadata, not a record. so we can only deploy metadata or change using setup.
It supports record modification only in Manage Package and within the same namespace.
4.It is not supporting lookup relationships with another custom settingCan be set lookup relation with another custom metadata.
5.Cannot use validation rule and page layout.Can be set validation rule and page layout.
6.Supporting few basic data types and not supporting picklist, text area, or lookup fieldsWe can create picklist fields in, a long text area and we can also add validation rules to it.

Where Custom Metadata Types should be used

  1. Custom Metadata types are configurable data objects so we should use them where application configuration is not changing between org.
  2. We should use it in AppExchange product to add configuration data. We can give functionality to edit records to the app’s consumer as well using its visibility setting.

Where Custom Setting should be used

  1. It should be used when we have to configure different data for different org like API URLs which will be different for different org etc.
  2. We should use it when we want to configure different data for a different set of users/profiles.

References:

Custom Settings

Custom Metadata Types

Related Posts:

What is SOQL Injection?

What is PK Chunking?

What is Data Skew?

What are Skinny Tables?

You may also like

3 comments

What are Salesforce Big Objects? - SalesforceCodex July 18, 2022 - 5:05 am

[…] Custom Setting and Custom Metadata Type […]

Reply
Salesforce Architect Interview Questions - Salesforce Codex March 6, 2024 - 4:44 am

[…] out the post-Custom Setting and Custom Metadata Type to understand the both […]

Reply
Questions for Tech Lead/Salesforce Architect Interview May 15, 2024 - 12:37 am

[…] Interview QuestionsSalesforce Apex Interview QuestionTypes Of Integration Patterns in SalesforceDifference Between Custom Setting and Custom Metadata TypeWhat is PK Chunking?What is Data […]

Reply

Leave a Comment

Top 10 Salesforce Service Cloud Features Top 10 Best Practices for Lightning Flow Facts and Statistics for Salesforce’s Size and Market Share Top 5 Contract Management Salesforce Apps Top 10 Enterprise Integration Use Cases