This question seems pretty easy and a decision could be straightforward in choosing Custom metadata vs Custom Object. However, I wish it could have been that easy, it’s not as simple as choosing between black & white color.
Many of my clients, struggling because of over usage of Custom metadata. Eventually, when there really is a need to choose custom metadata, they are already exhausted or near to reaching 10 Million character limits in Custom Metadata.
As I advise them on what are my thumb rules, thought to put a quick & very simple blog post. I would welcome all of your feedback & comment in this blog post to see if I can improve recommendations.
1. Controlling Application Behavior
If you want your customizations or configurations to behave differently depending on this data, then choose – Custom Metadata. Examples could be an On-Off switch for the trigger, assigning a queue on basis of the configured region, etc.
2. Need to use in Validation rule, Formula
If there is a need to use data in the Validation rule, formulas, flows, etc then choose Custom Metadata.
3. Data Maintained by System Admin or Business Users
If data needs to be maintained by business users who would not have access to Setup & Configurations then use Custom Object. If data needs to be updated & managed by the System admins only, we can still use custom objects & control visibility using profiles or permission sets. This is really not a strong case for using custom metadata.
4. Reporting or Refer to existing custom or standard object
Custom metadata does support parent-child relationships but to other custom metadata only. Therefore, if we need to refer to any existing standard or custom object, then we have to choose a custom object.
Another important aspect is reporting capability needs. If we want standard Salesforce reports to work, we would need Custom Object.
5. Moving data between orgs
Custom metadata can be deployed using tools like changeset, and SFDX. However, I still don’t see it as a enough strong reason to use the custom metadata. We can always have a command line data loader to load records or an Apex class to read static resources and load data if needed.
6. Governor Limit on the volume of records – Important
In my opinion, this is the most important area that needs due diligence. Custom Objects records only take 2kb of space, no matter how much content there is. However, custom metadata size is decided on basis of field size & not actual records. So, if you have a text field of size 255 characters and storing only 10 characters, Salesforce would still count it as 255 characters.
The Governor limit is 10 million characters for custom metadata, and you might think it’s more than enough. Let me give you an example breakdown :
Let’s assume, you have 5 custom metadata defined in your org. Assume, each custom metadata has 20 fields of type text with 255 characters size. If each custom metadata has even 500 records, you would hit the 10 Million characters limit.
The thumb rule that I follow is – If there is a need for around 30 fields and the total number of records could exceed 100, I reevaluate my solution very carefully to make sure the application is scalable in the future.
7. Encryption need
Custom metadata does not support encryption. If you are in the healthcare industry and security, compliance is paramount, you might need to go with Custom Objects.
Above are 7 areas I evaluate and depending on the overall score, it makes things clear on what to choose between custom metadata & custom objects.
I have intentionally not mentioned other advantages of Custom Metadata like SOQL limit, performance because of caching, etc because they might not have a huge impact on decisions.
However, feel free to add some other dimensions that could help or impact your decisions.
Leave a Reply to Mitul PatelCancel reply