SaasGuru Logo

Kickstart your career with the World's First Salesforce & AI Programs by an IIT - Explore Courses 🎉

Kickstart your career with the World's First Salesforce & AI Programs by an IIT - Explore Courses 🎉
The Distinction Between Custom Settings and Custom Metadata in Salesforce

The Distinction Between Custom Settings and Custom Metadata in Salesforce

In the world of Salesforce development, administrators and developers often encounter the need to store and manage configurable business data that goes beyond the standard functionality provided by the platform. It can be static data or for some development purpose. This is where the concept of custom settings and custom metadata comes into play. 

While both serve as valuable tools for storing custom data in Salesforce, it is crucial to understand the differences between them to leverage their capabilities effectively. 

In this article, we will delve into the dissimilarities between custom settings and custom metadata, exploring their use cases, structure, and impact on Salesforce implementations.

saasguru Salesforce Labs: Real-time Projects for Practice

Custom Settings: A Deeper Look

Custom Settings in Salesforce provide a convenient way to store and retrieve custom data within your organization. They act as a configuration layer that allows you to define custom data objects at the organization, profile, or user level. Custom Settings are custom objects with a tabular structure, enabling you to create fields and records similar to standard and custom objects in Salesforce.

One of the primary advantages of Custom Settings is their ability to be easily accessed through Apex code, formulas, and validation rules. This accessibility makes them highly suitable for storing application settings, default values, and other data that need to be frequently referenced by your application.

Types of Custom Settings

Salesforce provides two types of custom settings: hierarchical and list. Let’s explore each of them in more detail:

Hierarchical Custom Settings

This type of custom setting allows you to define a hierarchical structure, similar to a tree, where you can have a combination of organization-level and profile-level settings. The organization-level setting acts as a default value, which can be overridden by profile-level settings if needed. This hierarchical structure grants you great flexibility in customizing the application behavior based on different profiles or users.

List Custom Settings

Unlike hierarchical custom settings, list custom settings do not possess a hierarchical structure. Instead, they allow you to create a list of custom records with their own set of fields. This type of custom setting is often used when you need multiple configuration records that do not require a hierarchical relationship. List custom settings provide a convenient way to manage multiple sets of configuration data and access them efficiently.

Custom Metadata: An In-Depth Analysis

On the other hand, Custom Metadata offers a more advanced and flexible way of storing custom data in Salesforce. Custom Metadata allows you to define custom data types and records that are customizable and deployable across different Salesforce orgs. Unlike Custom Settings, Custom Metadata provides a metadata layer, allowing for easier management and deployment of configuration data.

Types of Custom Metadata

Custom Metadata Types

Custom Metadata Types act as templates to define the structure of the custom metadata records. They consist of fields, relationships, and other customizations similar to custom objects.

Custom Metadata Records

Custom Metadata Records are instances of Custom Metadata Types. These records store the actual data, allowing you to create multiple records with different values based on the Custom Metadata Type definition.

Difference Between Custom Setting and Custom Metadata in Salesforce

 Custom SettingsCustom Metadata
DefinitionCustom Setting is a type of object in Salesforce that allows you to create custom data storage at the organization, profile, or user level. It is stored in the application cache and can be accessed through the Apex code.Custom Metadata is also a type of object in Salesforce that allows you to create custom data storage, but it is customizable at the metadata level and can be deployed between different environments.
ScopeCustom settings have a hierarchical scope. You can define custom settings at the organization level (default), profile level, or specific user level. This allows you to have different values for custom settings based on different contexts.Custom metadata types have a global scope. The values stored in custom metadata are shared across the entire Salesforce org and cannot be scoped to specific profiles or users. Custom metadata is generally used for shared configuration data that applies to all users.
DeploymentCustom settings are deployable using change sets or other deployment tools. You can package and deploy custom settings along with other components to different environments.Custom metadata types are deployable using Change sets, Metadata API, or the Salesforce CLI. They can be included in a package.xml file or deployed using tools like Salesforce DX. Custom metadata provides a more flexible and granular deployment mechanism.
Configuration OptionsCustom Settings can be configured using a user interface in Salesforce setup.Custom Metadata can only be configured using the Metadata API or through the Salesforce CLI.
VersioningCustom settings do not have built-in versioning. If you need to maintain different versions of your custom settings, you would need to handle versioning manually.Custom metadata types have built-in versioning support. You can create different versions of a custom metadata type and track changes over time. This is particularly useful for managing configuration changes and maintaining a history of metadata revisions.
Access ControlCustom Settings have their own access controls and can be made visible to specific profiles and users.Custom Metadata records can be accessed by all users, but you can control the visibility of custom metadata types using permissions.
ScalabilityCustom Settings have some limitations on the number of records and field types.Custom Metadata has a higher limit on the number of records and can have a more complex structure.
Dependency ManagementCustom settings do not support dependencies between components. If you have dependencies between custom settings and other metadata, you need to handle those dependencies manually during deployment or through custom development.Custom metadata types support dependencies between components. You can define dependencies between custom metadata types and other metadata components, ensuring that related components are deployed together. This simplifies the management of complex metadata relationships.
Record RelationshipsCustom Settings do not support relationships between records.Custom Metadata supports relationships between records within the same custom metadata type.
Data AccessCustom Settings can be accessed synchronously in Apex code.Custom Metadata records can be accessed synchronously in Apex code or asynchronously through the Metadata API.
Visibility and ModifiabilityCustom settings are visible and modifiable by administrators and developers through the Salesforce UI or API.Custom metadata types are visible and modifiable only by administrators and developers through the Salesforce UI, API, or Metadata API. They are not directly accessible to end users.
DML in ApexCRUD operations can be performed on custom setting data in Apex. This means that you can create, retrieve, update, and delete records of custom settings programmatically.CRUD operations cannot be performed directly on custom metadata types in Apex. Custom metadata records are treated as metadata, and they can only be modified via the Metadata API, not through DML operations.
SuffixCustom settings have a suffix of “__C” appended to their API names. This naming convention helps differentiate them from standard objects.Custom metadata types have a suffix of “__mdt” added to their API names. This naming convention distinguishes them from other types of metadata.
Refreshing DataCustom Settings require a refresh or restart of the application to reflect changes.Custom Metadata changes are automatically reflected in the application without requiring a refresh or restart.
Usage ScenariosCustom Settings are suitable for storing configuration data and application settings.Custom Metadata is suitable for storing metadata configurations and dynamic data that need to be deployed and managed separately from the code.
SOQLCustom-setting data can be accessed using instance methods, which allows you to avoid making SOQL queries to the database. Custom-setting records are cached in memory once they are accessed, providing faster access to the data.With custom metadata types, you can issue unlimited SOQL queries for each Apex transaction. However, it’s important to note that custom metadata queries are subject to the normal governor limits. Alternatively, you can also use custom metadata relationships or custom metadata types’ description methods to access the data without using SOQL queries.
Apex Trigger SupportCustom Settings can have triggers associated with them.Custom Metadata does not support triggers.
Search FunctionalityCustom Settings do not support SOQL or SOSL queries.Custom Metadata supports SOQL queries for accessing and filtering records.
Testing and MockingCustom Settings can be easily mocked in unit tests.Custom Metadata records require more complex mocking in unit tests.
Test ClassThe data stored in custom settings are not visible or accessible in test classes by default. Test classes cannot directly access or manipulate custom-setting data.In contrast, the data stored in custom metadata types are visible and accessible in test classes without requiring the use of the “SeeAllData” annotation. Test classes can access and manipulate custom metadata data directly.
Change TrackingCustom Settings do not support change tracking.Custom Metadata supports change tracking, allowing you to track changes to metadata records over time.
Field-Level SecurityCustom Settings do not support field-level security.Custom Metadata does not support field-level security.
Integration ConsiderationsCustom Settings are not directly available in the Metadata API and require custom handling.Custom Metadata is available in the Metadata API and can be easily integrated with other metadata components.
Salesforce ConnectCustom Settings cannot be used with Salesforce Connect (formerly known as Lightning Connect).Custom Metadata cannot be used with Salesforce Connect (formerly known as Lightning Connect).

Conclusion: Choosing the Right Option

Salesforce Training Program India

In summary, custom settings and custom metadata provide Salesforce administrators and developers with valuable tools for storing and managing custom data. While custom settings offer simplicity and flexibility, custom metadata takes customization to a metadata level, enabling enhanced configuration and deployment capabilities.

When deciding between custom settings and custom metadata, consider the specific requirements of your Salesforce implementation. If you need a straightforward and flexible solution that adapts to various levels of the Salesforce hierarchy, hierarchical or list custom settings may be the way to go. On the other hand, if you require extensive customization, metadata-driven configuration, and seamless deployment, custom metadata is the ideal choice.

By understanding the distinctions between custom settings and custom metadata, you can leverage their unique strengths to optimize your Salesforce implementation and propel your organization toward success.

Check out our Salesforce Admin training program – get 2X Salesforce certified and job ready.

If you still have questions, feel free to join our saasguru Slack Community and get in touch with the industry experts for FREE! 

Table of Contents

Subscribe & Get Closer to Your Salesforce Dream Career!

Get tips from accomplished Salesforce professionals delivered directly to your inbox.

Looking for Career Upgrade?

Book a free counselling session with our Course Advisor.

By providing your contact details, you agree to our Terms of use & Privacy Policy

Unlock Your AI -Powered Assistant

Gain Exclusive Access to Your Salesforce Copilot

Related Articles

Salesforce Announces Dreamforce 2025: Dates and Key Details

Discover the latest updates on Dreamforce 2025, including dates, location, and what to expect from Salesforce’s premier event. Read now!

Salesforce Named a Leader in 2024 for Multichannel Marketing Hubs

Salesforce recognized as a Leader in 2024 Gartner Magic Quadrant for Multichannel Marketing Hubs, driving personalized, cross-channel engagement.

Salesforce October 2024 Updates by saasguru

Salesforce’s October 2024 updates bring AI innovations, partnerships, and recognitions, driving cloud solutions across industries. Read now!