+ Start a Discussion
Daniel FullerDaniel Fuller 

How do I Retrieve Metadata Components from Multiple Packages Using the ANT Salesforce Migration Tool?

I currently have a Sandbox and Production org where I am trying to perform an sf:retrieve on all of the metadata components in the org, both unpackaged and packaged components. I have been able to perform the retrieve on the unpackaged components successfully. However, there are two packages in the org from which I need to retrieve components. In the documentation for the Salesforce Migration Tool, it mentions that the "packageNames" attribute can receive a comman-separated list of package names to be retrieved. However when I have attempted to the the following syntax, I receive an API error from Salesforce stating, "Failed to process the request successfully. Cause(INVALID_CROSS_REFERENCE_KEY): INVALID_CROSS_REFERENCE_KEY: More than 1 package retrieved with single package flag."

Syntax:
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="targetFolder" packageNames="PackageName1,PackageName2"/>

I have also tried using the same comma-separated list in the build.properties file with the syntax:
sf.pkgName = Package1, Package2
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="targetFolder" packageNames="${sf.pkgName}"/>

I received the same error doing it this way as well.

I am not sure how the package names should be separated in order to avoid this API error or if there might be some other cause?

Any help would be greatly appreciated. Thank you!
 

Maggie LongshoreMaggie Longshore
Add attribute singlePackage="false" to your retrieve target. The default is true which denotes 1 package.