Custom Setting Vs Custom Metadata in Salesforce
Custom Setting Vs Custom Metadata in Salesforce
Vs
Custom Metadata In
Salesforce
#kb_sfdc_content
Custom Settings Custom Metadata
Configuration Custom Settings can be configured using a user Custom Metadata can only be configured using the
Options interface in Salesforce setup. Metadata API or through the Salesforce CLI.
#kb_sfdc_content
Custom metadata types have built-in versioning support.
Custom settings do not have built-in versioning. If you You can create different versions of a custom metadata
Versioning need to maintain different versions of your custom type and track changes over time. This is particularly
settings, you would need to handle versioning manually. useful for managing configuration changes and
maintaining a history of metadata revisions.
Record Custom Settings do not support relationships between Custom Metadata supports relationships between
Relationships records. records within the same custom metadata type.
Custom Metadata records can be accessed
Custom Settings can be accessed synchronously in
Data Access synchronously in Apex code or asynchronously through
Apex code.
the Metadata API.
#kb_sfdc_content
Custom metadata types are visible and modifiable only by
Custom settings are visible and modifiable by
Visibility and administrators and developers through the Salesforce UI,
administrators and developers through the Salesforce UI
Modifiability API, or Metadata API. They are not directly accessible to
or API.
end users.
CRUD operations cannot be performed directly on
CRUD operations can be performed on custom setting
custom metadata types in Apex. Custom metadata
data in Apex. This means that you can create, retrieve,
DML in Apex records are treated as metadata, and they can only be
update, and delete records of custom settings
modified via the Metadata API, not through DML
programmatically.
operations.
Custom settings have a suffix of “__C” appended to their Custom metadata types have a suffix of “__mdt” added to
Suffix API names. This naming convention helps differentiate their API names. This naming convention distinguishes
them from standard objects. them from other types of metadata.
Custom Settings require a refresh or restart of the Custom Metadata changes are automatically reflected in
Refreshing Data
application to reflect changes. the application without requiring a refresh or restart.
Custom Metadata is suitable for storing metadata
Custom Settings are suitable for storing configuration
Usage Scenarios configurations and dynamic data that need to be
data and application settings.
deployed and managed separately from the code.
With custom metadata types, you can issue unlimited
Custom-setting data can be accessed using instance SOQL queries for each Apex transaction. However, it’s
methods, which allows you to avoid making SOQL important to note that custom metadata queries are
SOQL queries to the database. Custom-setting records are subject to the normal governor limits. Alternatively, you
cached in memory once they are accessed, providing can also use custom metadata relationships or custom
faster access to the data. metadata types’ description methods to access the data
without using SOQL queries.
#kb_sfdc_content
Apex Trigger
Custom Settings can have triggers associated with them. Custom Metadata does not support triggers.
Support
Search Custom Metadata supports SOQL queries for accessing
Custom Settings do not support SOQL or SOSL queries.
Functionality and filtering records.
Testing and Custom Metadata records require more complex mocking
Custom Settings can be easily mocked in unit tests.
Mocking in unit tests.
Field-Level Security Custom Settings do not support field-level security. Custom Metadata does not support field-level security.
Integration Custom Settings are not directly available in the Metadata Custom Metadata is available in the Metadata API and
Considerations API and require custom handling. can be easily integrated with other metadata components.
Custom Settings cannot be used with Salesforce Connect Custom Metadata cannot be used with Salesforce
Salesforce Connect
(formerly known as Lightning Connect). Connect (formerly known as Lightning Connect).
#kb_sfdc_content
#kb_sfdc_content