Table of Contents
Custom Settings in Salesforce
Custom settings are like custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or unique user. So, this facts can be utilized by formula fields, validation rules, Apex, and the SOAP API.
There are two types of custom settings:
List Custom Settings:
A type of custom setting that provides a reusable set of static data that can be accessed across your organization.So, if you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it.
Here we can store our data and display that data without using SOQL. If we are using SOQL to fetch or display same record for multiple times it might hit governing limit ,to avoid that we can use list custom setting.
Hierarchy Custom Settings:
Hierarchy settings allow you to personalise your application for different profiles and/or users. A type of custom setting that uses a built-in hierarchical logic that lets you “personalise” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.
This type of custom setting that help to customise settings for specific profiles or users. The hierarchy logic checks the organization, profile, and users. So, we can override profile or user organization per wide. We can by-pass validation to a particular profile or user.
Limits in Custom Settings:
1. The total amount of cached data allowed for your organization is the lesser of these two values:
i. 10 MB
ii. 1 MB multiplied by the number of full-featured user licenses in your organization
2. Each Certified managed package gets its own separate limit in addition to your organization limit.
3. 300 fields per custom setting.
4. You can’t share a custom setting object or record.
5. No owner is assigned when a custom setting is created, so the owner can’t be changed.
6. Custom settings are a type of custom object. And each custom setting counts against the total number of custom objects available for your organization.
Custom Metadata Types
Custom metadata is customisable, deployable, package-able, and upgradeable application metadata. Firstly, you create a custom metadata type, which defines the form of the application metadata. Then you build reusable functionality that determines the behaviour based on metadata of that type. Similar to a custom object or custom setting, a custom metadata type has a list of custom fields that represent aspects of the metadata. When you package a public custom metadata type, customers who install the package can add their own records to the metadata type.So, your reusable functionality reads your custom metadata and uses it to produce customised application behaviour.
Custom metadata rows resemble custom object rows in structure. You create, edit, and delete custom metadata rows in the Metadata API or in Setup. Because the records are metadata, you can migrate them using packages or Metadata API tools. Custom metadata records are read-only in Apex and in the Enterprise and Partner APIs.
Difference Between Custom Settings and Custom Metadata Types
Main difference between custom metadata and custom setting is that custom metadata records are deployable and packageable. But we can not deploy custom setting data.
Here is listing of Difference Between Custom Setting and Custom Metadata Type
1. Custom settings permit you to create custom sets of data, in addition to create and associate custom data for an organisation, profile, or precise user. Custom metadata are like custom setting however records in custom metadata type taken into consideration as metadata as opposed to data.
2. There are 2 types of custom setting List and Hierarchy Custom setting. There are no such types in custom metadata. Also, Custom metadata does not support Hierarchy type of data based on user profile or specific user.
3. Custom settings do now no longer assist relationship fields. But you can create lookups among Custom Metadata objects.
4. You can get admission to custom setting data the usage of example strategies and might keep away from SOQL queries to database. So, with custom metadata types, you could problem limitless Salesforce Object Query Language (SOQL) queries for every Apex transaction.
5. Custom metadata types are seen in take a look at magnificence with out “SeeAllData” annotation however custom putting facts isn’t seen.
6. Custom metadata facts are deployable however custom putting facts isn’t.
Advantages to Custom Metadata:
1. Most importantly, as said before, they’re Metadata and therefore deplorable! No extra traumatic configuration after deployment, which you need to do with Custom Settings. They’re additionally refreshed to sandboxes, so that you do not want to create Apex instructions to generate your default Custom Setting statistics.
2. They have WAY extra alternatives that Custom Settings: picklist fields, lengthy textual content areas (in Spring ’17), web page layouts, and validation rules (aleven though as of Winter ’17 those aren’t deployable both via way of means of alternate set or via way of means of migration tool – weird!)
3. The splendor this is Metadata Relationships! You can create lookups among Custom Metadata items. Additionally, you could create an Object Definition research – so that you’re referring to Custom Metadata to Standard or Custom Object definitions. Additionally, in Spring ’17 you could create a structured research to a Field Definition on that object. (Documentation here)
4. Custom Settings have the identical permission to edit the statistics and to edit the configuration. Both may be achieved with the “Configure Application” permission. With Custom Metadata, you could edit the statistics with “Configure Application” however you require “Author Apex” to edit the configuration.
5. Custom Metadata types have a whole lot of extra capabilities particular to growing controlled packages. So, you can configure the visibility and editability of fields an items each via way of means of the org that installs the bundle and via way of means of enhancements to the bundle.
Reason why you would use custom setting instead:
1. Hierarchies – Custom metadata kinds do now no longer purport to update hierarchy custom settings which assist you to range values primarily based totally on customers and profiles throughout the org. These custom settings also can be referenced in formulas, so may be utilized in formulation fields, validation rules, workflow rules, and visualforce.
2. Web carrier credentials – If you’re the usage of take a look at credentials in a sandbox, you don’t have any purpose to installation them to manufacturing. More importantly, in case you create a sandbox, you don’t need the config for the manufacturing variations of your Web Services being created robotically and utilized by default. However, it’s also exceptional to apply Named Credentials for this.
3. Custom putting records’ values may be edited in code, whilst custom metadata cannot. So, if you may want to regulate your configuration programmatically for any purpose (say you’re growing a config console for the user), custom metadata will now no longer work.
For more details refer to official link.
For something like lists of countries and provinces: Custom Metadata for sure, easy to deploy from org to org, usually better than List Custom Settings.
Reasons for using Custom Settings: for org-specific, single-value settings that you never want to deploy (and overwrite accidently). Feature toggles, indication that all data is testdata, token for some external service.
Thank you for sharing.
Hi my family member! I wish to say that this article is amazing, great written and include approximately all important infos. I?d like to peer extra posts like this .
Uѕually I don’t read post on blogs, but I wish to
say that this write-up very forced me to take a look at and do іt!
Υour writing style has been amazed me. Thank ʏou, qսіte great post.
I’m not sure where you’re getting your information, but great topic. I needs to spend some time learning much more or understanding more.
Thanks for fantastic information I was looking for this information for my mission.
There is noticeably a bundle to identify about this. I assume you made various good points in features also.
I do not even know how I finished up right here, but I thought this submit was good. I do not understand who you are however definitely you are going to a well-known blogger if you happen to aren’t already 😉 Cheers!