I am trying to deploy a field on a custom metadata type using Ant.
Here's my package.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>CustomMetadata</name>
</types>
<version>43.0</version>
</Package>
Then inside a customMetadata
folder I have a file called nameOfMtdType.NameOfField.md
. That file's content looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<values>
<fullName>Number_Of_Balls__c</fullName>
<description>The maximum number of balls that are allowed.</description>
<externalId>false</externalId>
<fieldManageability>DeveloperControlled</fieldManageability>
<inlineHelpText>The maximum number of balls that are allowed.</inlineHelpText>
<label>Number Of Balls</label>
<precision>4</precision>
<required>false</required>
<scale>0</scale>
<type>Number</type>
<unique>false</unique>
</values>
</CustomMetadata>
I am getting this error: Error parsing file: Element {http://soap.sforce.com/2006/04/metadata}fullName invalid at this location in type CustomMetadataValue
What am I doing wrong? The content inside the <values></values>
is what I pulled from my scratch org using sfdx.
Also, I was trying to follow the documentation from this link: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_custommetadata.htm
Is there a better resource?
Best Answer
The Metadata API type
CustomMetadata
is for deploying records of Custom Metadata Types, not the schema of the type itself. That's why you're getting back that error - you supplied part of the type definition where Salesforce was looking for record data.The Custom Metadata Type itself, along with its fields, is deployed as a
CustomObject
, where properties likefullName
are expected. There's an example in that documentation of what it looks like to deploy a Custom Metadata Type field for a type calledReusablePicklistOption__mdt
:ReusablePicklistOption__mdt.object
The easiest way to handle this, though, is just to let Salesforce DX convert the source for you with the
force:source:convert
command. You can then trim the converted Metadata API source andpackage.xml
down to deploy just the elements you're interested in, like this single field.