Most of you must already know that there is new way to control your program behavior in Salesforce with the help of Custom Metadata Types. Previously we were using List Custom Settings to create functionalities like managing Trigger’s On/Off behavior or controlling Integration endpoint URLs. However we were not able to use Migration tools to import export records into custom settings.
So, into the new world of Custom Metadata Types, I used change sets mostly to perform deployments. Recently, I needed to use ANT migration toolkit to retrieve and deploy Custom Metadata Types. I was able to do it however If you ask me, I spent more time then expected.
Received errors like :
package.xml - Entity type: 'CustomMetadata' is unknown
Just to make sure not to repeat same mistake and save time in future, lets discuss how we can import / export or rather I will say retrieve and deploy Custom Metadata Types in Salesforce using ANT Migration toolkit.
For the sake of simplicity consider below Custom Metadata Type schema.
Below image shows sample records in Custom Metadata Types
So the question is, how do we retrieve and deploy above Custom Metadata Types in Salesforce ?
There are two steps to address it
- Include Custom Metadata Type schema in package.xml using CustomObject tag
- Include Custom Metadata Type records in package.xml using CustomMetadata tag
Sample Source code :
Leave a Reply