# Custom metadata types versus custom settings

*Platform Developer II Study Guide · Advanced Developer Fundamentals · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/platform-developer-ii/advanced-developer-fundamentals/custom-metadata-types-versus-custom-settings*

How to choose between custom metadata types, list custom settings and hierarchy custom settings, read them without spending SOQL, write custom metadata from Apex, protect secrets in packages and avoid the test and query traps each one sets.

- Certification: Salesforce Platform Developer II
- Exam section: Advanced Developer Fundamentals
- Study guide: https://www.certifyforce.com/study-guide/platform-developer-ii

**Official exam objective:**

> Given a scenario, identify best practices for various types of custom metadata and custom settings, and how to implement required solutions.

## What the exam expects

- Choose a custom metadata type, a list custom setting or a hierarchy custom setting from a requirement about deployment, per-user values, relationships or secrecy.
- Read each one in Apex without spending SOQL queries, and know when a query does count or a value is truncated.
- Update custom metadata records from Apex through the Apex Metadata API instead of DML.
- Protect secrets with protected custom metadata in a managed package, and pass custom metadata safely to components.
- Predict how tests see custom metadata and custom settings, and which declarative features can reference them.

Key terms: **custom metadata type** (`__mdt`: an object whose records are metadata, deployed with the app), **list custom setting** (cached org-wide data sets), **hierarchy custom setting** (cached values resolved user → profile → org), **Apex Metadata API** (the `Metadata` namespace that deploys custom metadata records), **protected** (visible only to code in the package's namespace).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Custom setting records in change sets | Not deployable; only the definition moves | [Get Started with Custom Metadata Types](https://trailhead.salesforce.com/content/learn/modules/custom_metadata_types_dec/cmt_overview) |
| SOQL on custom metadata | Unlimited, except long text area fields and flows | [Custom Metadata Allocations and Usage Calculations](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_limits.htm&type=5) |
| `getAll()` / `getInstance()` on `__mdt` | First 255 characters per field only | [Custom Metadata Type Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_metadata_types.htm) |
| SOQL on a custom setting | Skips the application cache, like a custom object query | [Custom Settings Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_settings.htm) |
| Custom metadata delete from Apex | Not supported; create and update only (subscriber-controlled, visible records) | [Develop and Test with Custom Metadata Types](https://trailhead.salesforce.com/content/learn/modules/custom_metadata_types_adv/cmt_develop) |
| Formula fields and custom settings | Hierarchy only, via `$Setup` | [Access Custom Settings with Code](https://help.salesforce.com/s/articleView?id=platform.cs_accessing.htm&type=5) |
| Custom metadata types per org | 200, plus 150 more from certified managed packages | [Custom Metadata Allocations and Usage Calculations](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_limits.htm&type=5) |
| Custom settings cache | Lesser of 20 MB or 2 MB per full-featured license | [Custom Settings Limits and Considerations](https://help.salesforce.com/s/articleView?id=platform.cs_limits.htm&type=5) |

## Check yourself

- Why does `getInstance()` on a custom metadata type cut off a 2,000-character body?
- When should a developer choose a hierarchy custom setting over a custom metadata type?
- Why can't a custom metadata query use `OR` across `Country__c` and `Product_Line__c`?
- How does Apex change a custom metadata record at run time?

## Sources

- [Get Started with Custom Metadata Types](https://trailhead.salesforce.com/content/learn/modules/custom_metadata_types_dec/cmt_overview)
- [Define Custom Settings](https://help.salesforce.com/s/articleView?id=platform.cs_define.htm&language=en_US&type=5)
- [Protection and Privacy Options for Custom Metadata Types](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_protection.htm&language=en&type=5)
- [Custom Settings Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_settings.htm)
- [Custom Metadata Type Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_metadata_types.htm)
- [Custom Metadata Allocations and Usage Calculations](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_limits.htm&type=5)
- [Custom Metadata Types Limitations](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_limitations.htm&type=5)
- [Operations Class](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_Operations.htm)
- [Develop and Test with Custom Metadata Types](https://trailhead.salesforce.com/content/learn/modules/custom_metadata_types_adv/cmt_develop)
- [Custom Settings](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_customsettings.htm)
- [Custom Metadata Relationships](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_relationships.htm&type=5)
- [Access Custom Settings with Code](https://help.salesforce.com/s/articleView?id=platform.cs_accessing.htm&type=5)
- [Custom Settings Limits and Considerations](https://help.salesforce.com/s/articleView?id=platform.cs_limits.htm&type=5)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 15 linked practice questions, and unlimited timed mock exams are included with the Platform Developer II pack (USD $19): https://www.certifyforce.com/practice-exams
