I'm looking for some guidance on how this tool is widely used.

We have the following scenario:

Source: 1x Production org, with 1 (or more) managed packages installed. Targets: Multiple Production orgs, with 1 (or more) managed packages installed.

We are an ISV, and our managed package will be installed in each of the Production orgs mentioned above.

Our challenge is trying to retrieve metadata data from the source org. and deploy to multiple targets orgs.

Here are the main issue we have come up against thus far:

Managed components are retrieved when retrieving metadata from the source org. This means we cannot deploy the metadata until we manually manipulate the metadata files, removing any managed content. This is incredibly time consuming. The only solution we have found thus far is to manually compile unpackaged/package.xml, explicitly including only those unmanaged custom components which we want to retrieve. This is also very time consuming.

So far, I've dabbled in Ant replaceregexp scripts to remove the managed components from the metadata files, but have been unsuccessful.

For example:

<target name="removeManagedFields">
    <replaceregexp  flags="gis" 
        <substitution expression=""/>
        <fileset dir="${sf.retrieveFolder}">
            <include name="**/*.object"/>

Has anyone come across this issue before and if so, how did you deal with it?

If anyone has any Ant scripts that they have written to get around common cross-organisation deployment issues that they don't mind sharing it would be greatly appreciated.


  • When you say "retrieve metadata data from the source org" do you mean non-managed package code/components that you have also added? Our strategy when developing such code is to dedicate a developer edition org to each customer and only ever transfer from that to the customer sandbox or production orgs so there is never any spurious content that needs removing.
    – Keith C
    Commented Mar 13, 2014 at 14:11
  • For example, when I use: <members>*</members> <name>CustomObject</name> There are two immediate problems: 1. Fields from the managed package are included in the object files, and throw errors when we try to deploy. 2. This approach does not retrieve custom unmanaged fields from managed custom objects. This can cause dependacy issues. Commented Mar 13, 2014 at 14:59

4 Answers 4


One possible solution is to use Packages as a container for your code. This allows you to retrieve only the code in your package from an org which ignores all other metadata in the org such as managed package fields, standard Salesforce fields, and any customer created fields.

To test it out, go to Setup->Create->Packages in your source org. Create an unmanaged package and use the Add Components button to add all the metadata you want to bundle in your package. Then, retrieve all metadata from the package into a folder. You'll wind up with a folder containing all the metadata and a package.xml file formatted to allow deployment into a Package in your target orgs.

The key difference in the package.xml is the inclusion of the element which flips on the deploy to package functionality.

The one catch is the target org will need to have a package with the same name already created before the deployment but this is a one time manual step per target org.

I just wrote up the build.xml targets in a different answer you can reference here: https://salesforce.stackexchange.com/a/31437/4832

There are, however, some drawbacks. Some metadata types won't deploy this way. For example, ActionOverrides don't work this way as they can't be bundled in a package. As a workaround, you can create a normal bundle of metadata for use only in deploying the types you can't deploy as part of a package.


One more possible solution is by following the below steps :

1> Use sf:listMetadata task of Force.com migration tool to retrieve
the information of all items(including managed package) of any
specific metadata type.

2> Use a script, may be a generic java program to filter out the
required items from the list above. We will get the names of final
list of components of any metadata type using this step.

3> Now finally using the final list in package.xml and use
sf:retrieve task of Force.com migration tool.

Using this approach you can retrieve the metadata components without much manual intervention from your Salesforce org and that too in no time.

You can check out the below link for more details: Retrieve list of components of any metadata type from a managed package

For your use case , in the generic properties.file , you can simply change the setting includePackage from true to false. And your are done.



In response to the comments on the question...

Below is an extract from a package.xml where we have one of our managed packages (namespace cve) deployed and then add custom fields and objects (and code and other components) in unmanaged (no namespace) form. The only CustomObject references we make are to entirely new objects. Any fields we add (or modify such as changing picklist contents) are referenced using CustomField. That does result in a .object file but it only contains the nominated fields. (Note this does not allow an occasional object-level setting to be preserved and manual steps are needed for those.)

But I'm probably still not following you as I don't understand your problem 1: if the managed package is installed in both the source and destination orgs why does the presence of managed package fields cause errors when you deploy to the destination org?


Only one managed package will be available in developer edition .Managed packages will not be supported in other editions . name space prefix will not be available in other editions.So this might be cause of the problem. We can deploy managed packages between dev orgs only.





You must log in to answer this question.

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