What are Custom Metadata Types and how do they differ from Custom Settings?
Suggested answer
Custom Metadata Types (CMT): Store configuration data as metadata — deployable via Metadata API, change sets, and packages. Records appear in package deployments like code. Accessible via SOQL in Apex. Cacheable — Salesforce caches CMT records in the application tier, reducing query overhead. Best for: integration endpoints, feature flags, validation rule configurations, threshold values that vary by environment.
Custom Settings: Store configuration data as custom objects — two types: List (multiple rows, queryable) and Hierarchy (per-org, per-profile, or per-user values). Accessible via MySettings__c.getInstance() without SOQL in List type settings. Limitation: Custom Settings are not deployable as data via Metadata API (only the schema deploys; data must be manually re-entered or scripted). Note: Salesforce is encouraging migration from Hierarchy Custom Settings to Custom Metadata Types.
Key difference: CMT records deploy with the metadata; Custom Settings data does not. For configuration that varies between sandboxes and production (URLs, credentials, feature flags), CMT is strongly preferred.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.