0

I have been using https://cloudtoolkit.co Package Builder to create a package.xml file listing all of my Org's metadata components. I am seeing some interesting behavior around InstalledPackage metadata. For example we have b2bmaIntegration package installed (used for Pardot), and when I receive xml file from the Package Builder I see duplicate values:

    <types>
    <members>acpoll</members>
    <members>b2bma</members>
    <members>b2bma</members>
    <members>b2bma</members>
    <members>b2bma</members>
    <members>b2bma</members>
    <members>b2bma</members>
    <members>BeeFree</members>
    <members>ca_collab_2_0</members>
    <name>InstalledPackage</name>
    </types>

Any idea why is this happening? Can I just clean up all the duplicate values before I do the pull? Any other tool I should be using to create package.xml file?

Thanks in advance.

5

1 Answer 1

0

To retrieve or deploy list of installed packages, actually you don't need to list them all, you could use just * syntax

<types>

<members>*</members>

<name>InstalledPackage</name>

</types>

Also, if you really want to list all installed packages, you could use list:metadata Metadata API call or the SFDX counterpart like this

MY_XML="package.xml"
echo '<?xml version="1.0" encoding="UTF-8"?>\n' >> "$MY_XML"
echo '<Package xmlns="http://soap.sforce.com/2006/04/metadata">' >> "$MY_XML"
echo '    <types>' >> "$MY_XML"
for each in $(sfdx force:mdapi:listmetadata -m InstalledPackage --json | jq '.result[].fullName' -r); do
    echo "        <members>$each</members>" >> "$MY_XML"
done
echo '        <name>InstalledPackage</name>' >> "$MY_XML"
echo '    </types>' >> "$MY_XML"
echo '    <version>53.0</version>' >> "$MY_XML"
echo '</Package>' >> "$MY_XML"

====

Update, actually now I understand what you are talking about. Each time when you try to install or upgrade a package, InstalledPackage metadata record is created and duplicated even if no package update happens.

Instead, it is possible to use sfdx force:package:installed:list command to find out all the package and then dereference namespace prefix to build the package.xml you desire like following

MY_XML="package.xml"
rm $MY_XML
echo '<?xml version="1.0" encoding="UTF-8"?>\n' >> "$MY_XML"
echo '<Package xmlns="http://soap.sforce.com/2006/04/metadata">' >> "$MY_XML"
echo '    <types>' >> "$MY_XML"
for each in $(sfdx force:package:installed:list --json | jq '.result[] .SubscriberPackageNamespace' -r); do
    echo "        <members>$each</members>" >> "$MY_XML"
done
echo '        <name>InstalledPackage</name>' >> "$MY_XML"
echo '    </types>' >> "$MY_XML"
echo '    <version>53.0</version>' >> "$MY_XML"
echo '</Package>' >> "$MY_XML"

You must log in to answer this question.

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