When deploying a new Custom metadata
item, you may be confused about which items you need to include in the deployment.
This is because Custom metadata
is composed of two different metadata types: Custom metadata
and Custom object
.
Creating a new Custom metadata type in Salesforce
When you create a new Custom metadata
item, the actual definition of this item is a Custom object
with an _mdt
suffix.
Any custom fields you add to this Custom metadata
item will similarly belong to the Custom object
.
Before you create any records for the Custom metadata
item within Salesforce, you will not be able to find any Custom metadata
items in the comparison.
โ
Checking the Named items
for Custom metadata
in your comparison's filter will also not show any item with the same name as your new Custom metadata
item.
Deploying the new Custom object
will create the Custom metadata
object in your target.
Adding records to your Custom metadata object
Once you have added records to your Custom metadata
object, you will then be able to find Custom metadata
in the comparison.
You will now also be able to see the record appear under the list of Custom metadata
named items in the section called Specify named items and rules
:
To deploy this new Custom metadata
record, you will need to ensure the Custom object
it belongs to is also deployed, or you will get this Salesforce validation error that we've documented in below article:
โResolving validation errors - "Custom metadata type "XXX_mdt" is not available in this organization"
Summary
If you have no records added to your Custom metadata
object, then you will not be able to find any Custom metadata
items in your comparison.
Deploying just the Custom object
of the Custom metadata
will create the Custom metadata
container in your target.
To deploy a new Custom metadata
record, its container Custom object
also needs to be deployed.