Created
May 20, 2020 20:21
-
-
Save shanerk/7c2cc717305c3a97a176fc70ce7b0692 to your computer and use it in GitHub Desktop.
Pull down all custom metadata records for a Salesforce org and unpack them into the DX format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pull down all custom metadata records for a Salesforce org and unpack them into the DX format | |
# Run from the root of your Salesforce DX project, the script assumes that your project is a git repo | |
#!/bin/bash | |
mkdir .tmp | |
echo '<?xml version="1.0" encoding="UTF-8"?><Package xmlns="http://soap.sforce.com/2006/04/metadata"><types><name>CustomMetadata</name><members>*</members></types><version>41.0</version></Package>' > .tmp/package.xml | |
echo 'Retrieving metadata from Salesforce...' | |
sfdx force:mdapi:retrieve --retrievetargetdir .tmp/ --wait 5 --unpackaged .tmp/package.xml | |
echo 'Unzipping package...' | |
cd .tmp | |
unzip unpackaged.zip | |
cd unpackaged/customMetadata | |
echo 'Renaming md files to md-meta.xml...' | |
for f in *.md; do | |
mv -- "$f" "${f%.md}.md-meta.xml" | |
done | |
echo 'Moving metadata records...' | |
mv *.xml ../../../force-app/main/default/customMetadata | |
echo 'Cleanup...' | |
cd ../../.. | |
rm -rf .tmp | |
git status | |
echo 'Done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment