custom metadata type vs custom setting - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Jayesh ShewaleJayesh Shewale 

custom metadata type vs custom setting

Hi Everyone,

I am learning custom metadata types from Trailhead.
So I have following questions.

1. What is difference between custom settings and custom metadata types?
2. Suppose I have a scenario which can be achieved by custom setting as well as custom metadata types, then which approach should I utilise?
Thanks in Advance.
sakshi nagpalsakshi nagpal
Hi Jayesh,

Well, I've found that in only a few cases in which Custom Settings more useful. Custom Metadata types have a number of advantages that make them the correct choice to implement almost always.

Advantages to Custom Metadata:

1. Most importantly, as stated before, they are Metadata and thus deployable! No more annoying configuration after deployment, which you have to do with Custom Settings. They're also refreshed to sandboxes, so you don't need to create Apex classes to generate your default Custom Setting records.

2. They have WAY more options that Custom Settings: picklist fields, long text areas (in Spring '17), page layouts, and validation rules (though as of Winter '17 these are not deployable either by change set or by migration tool - weird!)

3. The beauty that is Metadata Relationships! You can create lookups between Custom Metadata objects. Additionally, you can create an Object Definition lookup - so you're relating Custom Metadata to Standard or Custom Object definitions. Additionally, in Spring '17 you can create a dependent lookup to a Field Definition on that object. (Documentation here)

4. Custom Settings have the same permission to edit the records and to edit the configuration. Both can be done with the "Configure Application" permission. With Custom Metadata, you can edit the records with "Configure Application" but you require "Author Apex" to edit the configuration.

5. Custom Metadata types have a lot of additional features specific to developing managed packages. You can configure the visibility and editability of fields an objects both by the org that installs the package and by upgrades to the package.

Reason why you would use custom settings instead:
1. Hierarchies - Custom metadata types do not purport to replace hierarchy custom settings which allow you to vary values based on users and profiles across the org. These custom settings can also be referenced in formulas, so can be used in formula fields, validation rules, workflow rules, and visualforce. (Documentation here)

2. Web service credentials - If you’re using test credentials in a sandbox, you don’t have any reason to deploy them to production. More importantly, if you create a sandbox, you don’t want the config for the production versions of your Web Services being created automatically and used by default. However, it is usually best to use Named Credentials for this.

3. Custom setting records’ values can be edited in code, while custom metadata cannot. If you will need to modify your configuration programmatically for any reason (say you’re creating a config console for the user), custom metadata will not work.

Also please check the below information link on this topic:

Please mark it as "Best Answer" right below the comment if it gives you idea regarding your solution, so that it will help others if they have similar issues in future.
Gail HallettGail Hallett
Thanks, Sakshi - this was exactly the information I was just looking for. Wish I could mark this as best answer! I'm just creating a checkbox setting that will allow us to turn off triggers or parts of code via Config as a safety measure. I've decided to go with Settings because there's no cost to accessing them in code and I may in the future want to turn them on and off via code.