I run the below command and it prints undefined.

~sfdx force:mdapi:listmetadata --metadatatype=EmailTemplate --targetusername=mysandbox --folder=unfiled$public

When I run the above command with --metadatatype=CustomObject, it is working fine but not for EmailTemplate

What is wrong I am doing here?

| improve this question | | | | |

$ is a reserved character in some terminals, so I had to escape $ like this --folder="unfiled\$public"

Here is the complete command that is working:

~sfdx force:mdapi:listmetadata --metadatatype=EmailTemplate --targetusername=mysandbox --folder=unfiled\$public

NOTE: I ran into this issue on macOS.

Here is the bash script I created to prepare pacakge.xml with all EmailTemplate component names from the org:

sfdx force:mdapi:listmetadata --metadatatype=EmailFolder --targetusername=devsandbox --json | jq '.result[].fullName' > 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
    echo "$folderName"
    rm -f temp_1.txt
    sfdx force:mdapi:listmetadata --metadatatype=EmailTemplate --folder=$folderName --targetusername=devsandbox --json | jq '.result[].fullName' >> temp_1.txt
    while IFS= read -r line1
        echo "    <members>$templateName</members>" >> package_temp.xml
    done < "temp_1.txt"
done < "$input"
echo "    <name>EmailTemplate</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
| improve this answer | | | | |
  • 1
    In some terminals. It's always worth the time to learn your OS's terminal, as you never know when you'll run in to some quirk of the OS. – sfdcfox Sep 29 '19 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.