{"id":6209,"date":"2017-08-27T22:52:44","date_gmt":"2017-08-27T22:52:44","guid":{"rendered":"http:\/\/www.jitendrazaa.com\/blog\/?p=6209"},"modified":"2017-08-27T22:52:44","modified_gmt":"2017-08-27T22:52:44","slug":"how-to-retrieve-and-deploy-custom-metadata-types-using-ant","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/how-to-retrieve-and-deploy-custom-metadata-types-using-ant\/","title":{"rendered":"How to Retrieve and Deploy Custom Metadata Types using ANT"},"content":{"rendered":"<p style=\"text-align: justify;\">Most of you must already know that there is new way to control your program behavior in Salesforce with the help of <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/custom-metadata-types\/\"><strong>Custom Metadata Types<\/strong><\/a>. Previously we were using <a href=\"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/storing-secrets-or-passwords-in-salesforce-video\/\">List Custom Settings<\/a> to create functionalities like managing Trigger&#8217;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.<\/p>\n<p style=\"text-align: justify;\">So, into the new world of Custom Metadata Types, I used change sets mostly to perform deployments. Recently, I needed to use <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/ant-migration-tool\/\">ANT migration toolkit<\/a> to retrieve and deploy Custom Metadata Types. I was able to do it however If you ask me, I spent more time then expected.<\/p>\n<p>Received errors like :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npackage.xml - Entity type: 'Custom\u200bMetadata' is unknown\r\n<\/pre>\n<p style=\"text-align: justify;\">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 <strong>retrieve and deploy Custom Metadata Types in Salesforce using ANT Migration toolkit<\/strong>.<!--more--><\/p>\n<p>For the sake of simplicity consider below Custom Metadata Type schema.<\/p>\n<figure id=\"attachment_6212\" aria-describedby=\"caption-attachment-6212\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6212\" src=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Schema.png?resize=640%2C621&#038;ssl=1\" alt=\"Salesforce Custom Metadata Type Schema\" width=\"640\" height=\"621\" srcset=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Schema.png?w=640&amp;ssl=1 640w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Schema.png?resize=300%2C291&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption id=\"caption-attachment-6212\" class=\"wp-caption-text\">Salesforce Custom Metadata Type Schema<\/figcaption><\/figure>\n<p>Below image shows sample records in Custom Metadata Types<\/p>\n<figure id=\"attachment_6213\" aria-describedby=\"caption-attachment-6213\" style=\"width: 641px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6213\" src=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Records.png?resize=641%2C234&#038;ssl=1\" alt=\"Salesforce Custom Metadata Type Records\" width=\"641\" height=\"234\" srcset=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Records.png?w=641&amp;ssl=1 641w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Salesforce-Custom-Metadata-Type-Records.png?resize=300%2C110&amp;ssl=1 300w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><figcaption id=\"caption-attachment-6213\" class=\"wp-caption-text\">Salesforce Custom Metadata Type Records<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">So the question is, how do we retrieve and deploy above Custom Metadata Types in Salesforce ?<\/p>\n<p style=\"text-align: justify;\">There are two steps to address it<\/p>\n<ol>\n<li style=\"text-align: left;\">Include Custom Metadata Type schema in <em>package.xml<\/em>\u00a0using\u00a0<strong>CustomObject\u00a0<\/strong>tag<\/li>\n<li style=\"text-align: left;\">Include Custom Metadata Type records in <em>package.xml<\/em> using\u00a0<strong>CustomMetadata\u00a0<\/strong>tag<\/li>\n<\/ol>\n<p>Sample Source code :<br \/>\n<script src=\"https:\/\/gist.github.com\/JitendraZaa\/0fccf2ec92b7a06649f9e3f2c4048100.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Salesforce ANT Migration toolkit to retrieve and deploy custom metadata types with record. Sample Package.xml and ANT script included. <\/p>\n","protected":false},"author":1,"featured_media":6214,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[262,353],"class_list":["post-6209","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","tag-ant-migration-tool","tag-custom-metadata-types"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Sample-of-Package.xml-to-deploy-Custom-Metadata-Types.png?fit=1051%2C330&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6353,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/use-metadata-api-with-salesforce-dx\/","url_meta":{"origin":6209,"position":0},"title":"Use Metadata API with Salesforce DX","author":"Jitendra","date":"November 12, 2017","format":false,"excerpt":"How to use SalesforceDX to deploy metadata in Sandboxes or Non-Scratch Salesforce instances","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Use Metadata API or Package.xml with Salesforce DX","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/11\/Use-Metadata-API-or-Package.xml-with-SFDX.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/11\/Use-Metadata-API-or-Package.xml-with-SFDX.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/11\/Use-Metadata-API-or-Package.xml-with-SFDX.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/11\/Use-Metadata-API-or-Package.xml-with-SFDX.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/11\/Use-Metadata-API-or-Package.xml-with-SFDX.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2892,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-migration-tool-ant\/","url_meta":{"origin":6209,"position":1},"title":"Complete Salesforce Deployment Guide using Ant Migration Tool","author":"Jitendra","date":"June 5, 2012","format":false,"excerpt":"Step by Step tutorial of Salesforce Migration using ANT tool with Proxy settings and retrieving content from Salesforce Organization. Also fix some common errors like java.lang.OutOfMemoryError or unable to find tools.jar","rel":"","context":"In &quot;Configuration&quot;","block_context":{"text":"Configuration","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/configuration\/"},"img":{"alt_text":"Salesforce Get ANT version ","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/06\/Salesforce-Get-ANT-version-Original.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/06\/Salesforce-Get-ANT-version-Original.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/06\/Salesforce-Get-ANT-version-Original.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5935,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/continuous-integration-ci-in-salesforce-using-team-foundation-server-tfs-video\/","url_meta":{"origin":6209,"position":2},"title":"Continuous Integration (CI) in Salesforce using Team Foundation Server (TFS) &#8211; Video","author":"Jitendra","date":"March 20, 2017","format":false,"excerpt":"Step by step guide to set up Continuous Integration (CI) for Salesforce using Team Foundation Server (TFS) with video tutorial","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Team Foundation Server (TFS) - New Build definition - Select repository","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/03\/Team-Foundation-Server-TFS-New-Build-definition-Select-repository.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/03\/Team-Foundation-Server-TFS-New-Build-definition-Select-repository.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/03\/Team-Foundation-Server-TFS-New-Build-definition-Select-repository.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/03\/Team-Foundation-Server-TFS-New-Build-definition-Select-repository.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5595,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/dynamically-remove-xml-content-from-metadata-before-salesforce-deployment-using-xmltask-video\/","url_meta":{"origin":6209,"position":3},"title":"Dynamically remove XML content from metadata before Salesforce deployment using xmlTask &#8211; Video","author":"Jitendra","date":"August 18, 2016","format":false,"excerpt":"Example - automatically remove listview before deployment","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Using XMLTask in ANT for Salesforce Deployment","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/08\/2016-07-15.png?fit=922%2C519&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/08\/2016-07-15.png?fit=922%2C519&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/08\/2016-07-15.png?fit=922%2C519&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/08\/2016-07-15.png?fit=922%2C519&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":5070,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/dependent-picklist-in-salesforce-flow-using-custom-metadata-type-video\/","url_meta":{"origin":6209,"position":4},"title":"Dependent picklist in Salesforce flow using Custom Metadata type &#8211; Video","author":"Jitendra","date":"December 7, 2015","format":false,"excerpt":"Salesforce flow is great alternative for Visualforce pages used by admin. I have written, multiple blog post on Salesforce flow already and in this post we will discuss how we can create dependent picklist in Flow. If you are already using flow, might know that creating dependent picklist is not\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Salesforce flow - Dependent picklist output","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/12\/Salesforce-flow-Dependent-picklist-output.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3814,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/introduction-to-flexipage-in-salesforce1-and-deploying-it-using-workbench\/","url_meta":{"origin":6209,"position":5},"title":"Introduction to Flexible page aka Lightning Page with example","author":"Jitendra","date":"April 12, 2014","format":false,"excerpt":"Display Visualforce page only in Salesforce1 mobile application and not in desktop version","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Access Salesforce1 from Browser","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/04\/Access-Salesforce1-from-Browser.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/04\/Access-Salesforce1-from-Browser.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/04\/Access-Salesforce1-from-Browser.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=6209"}],"version-history":[{"count":2,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6209\/revisions"}],"predecessor-version":[{"id":6215,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6209\/revisions\/6215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media\/6214"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=6209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=6209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=6209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}