Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Last active September 29, 2019 21:12
Show Gist options
  • Select an option

  • Save sfdcale/d4d400e42f0123bc0e90a01498341fd2 to your computer and use it in GitHub Desktop.

Select an option

Save sfdcale/d4d400e42f0123bc0e90a01498341fd2 to your computer and use it in GitHub Desktop.
This shell script prepares package.xml file with all of the custom objects present in the org
#!/bin/bash
sfdx force:mdapi:listmetadata --metadatatype=CustomObject --targetusername=sandbox --json | jq '.result[].fullName' > temp.txt
input="temp.txt"
rm -f package_temp.xml
echo "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n" >> package_temp.xml
echo "<Package xmlns=\"http://soap.sforce.com/2006/04/metadata\">" >> package_temp.xml
echo " <types>" >> package_temp.xml
while IFS= read -r line
do
objName="${line//\"/}"
echo " <members>$objName</members>" >> package_temp.xml
done < "$input"
echo " <name>CustomObject</name>" >> package_temp.xml
echo " </types>" >> package_temp.xml
echo " <version>46.0</version>" >> package_temp.xml
echo "</Package>" >> package_temp.xml
cat package_temp.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment