4

I'm trying to use the ant migration tool to retrieve all the Custom Metadata records for a single Custom Metadata Type. However, I can't figure out the syntax.

I would think that something like this would work:

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>State_Sales_Tax.*</members>
        <name>CustomMetadata</name>
    </types>
    <types>
        <members>State_Sales_Tax__mdt</members>
        <name>CustomObject</name>
    </types>
    <version>36.0</version>
</Package>

but no dice.

4 Answers 4

2

I don't think you would be able to do something like that. You either use a wild card character or mention the names of the individual elements directly.

Something like this.

<types>
    <members>State_Sales_Tax_1</members>
    <members>State_Sales_Tax_2</members>
    <members>State_Sales_Tax_3</members>
    <name>CustomMetadata</name>
</types>

(or)

<types>
    <members>*</members>
    <name>CustomMetadata</name>
</types>
0

Below is the package.xml to retrieve all the custom metadata

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
 <types>
<members>*</members>
<name>CustomMetadata</name>
 </types>
 <version>37.0</version>
 </Package>

You can specify the name to retrieve an individual

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
 <types>
<members>test1</members>
<name>CustomMetadata</name>
 </types>
 <version>37.0</version>
 </Package>
1
  • Anyway to retrieve the custom metadata type records using sfdx? When I used <members>*</members> <name>CustomMetadata</name> with the sfdx force:source:retrieve command I get the error "The specified metadata type is unsupported"
    – Rodrigo
    Sep 17, 2020 at 16:43
0

While this isn't possible using wildcards within a package.xml, you can do this with the metadata api by first doing a list call to retrieve all custom metadata types. From there you can filter down to your specific custom metadata type and build a package.xml for a retrieve call.

0

To Retrieve a Custom Metadata Records of Specific Custom MetaData Records. Here's what I did 1)

  1. Simple SOQL to get Developer Name of the CM records

  2. Pasted the results in Excel and appended

    membersTAG NameoftheCMObject(excluding __mdt).DeveloperName of the CM Records membersTAG

  3. Removed other members tags which retrieves other SF Org Data like Apex Classes etc in package.xml

  4. So My package XML only contains <xml...... CM.DeveloperNames(We simply paste the result of exercise in excel) . . . . CustomMetadata

  5. BOOM Just press Retreive source from ORG and DONE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .