2

Given a metadata like "ApexTrigger" is it possible using sf:bulkRetrieve to fetch all triggers except the triggers part of any managed package ?

EDIT:Also when we use sf:retreive using the package.xml and Wildchars, managed package components are also retrieved.

The reason is that I am using a script which fetches all the components of Given org dynamically but as it uses sf:bulkRetrieve all the metadata components has managed package components as well thus cannot be deployed using sf:deploy easily

2

I've found the best approach to doing this is to first bundle the metadata in the org into a Package. Then, you can retrieve only metadata from the package which will exclude all standard Salesforce metadata and metadata from other managed packages.

It's pretty easy to do. In the org where you want to extract metadata, go to Setup -> Create -> Packages. Create an unmanaged package. Then, use the Add Components button to add all the metadata you want to pull into the package. Once you have the metadata bundled, you can use the ant migration tool to fetch the metadata:

  <sf:retrieve 
    username="${sf.username}" 
    password="${sf.password}" 
    serverurl="${sf.serverurl}" 
    retrieveTarget="TARGET_DIR_PATH_HERE" 
    packageNames="PACKAGE_NAME_HERE"/>

I found this far easier than the previous way I was fetching metadata where I would have to run cleanup scripts to delete metadata I wasn't interested in (standard fields and managed package metadata).

It also allows you to play around with metadata in your org but not "commit" it to the package. For example, you can add a custom field called MyTest and not add it to your package. If you retrieve the package, the field will not be included in the retrieve. If you then add the field to the package via Add Components and then retrieve, you will get the field. It's a far more explicit approach to handling metadata retrieves in my opinion.

1
  • how did you deploy the package? After I retrieved my package using the same method as above I used the deployUnpackaged to deploy, unfortunately that just installed everything unpackaged. How do I deploy the package as a package? Thanks ahead of time! – user891859 Sep 19 '17 at 13:09
1

One way of doing this is to use the sf:listMetadata task of Force.com migration tool which will retrieve the information of all the items of any particular metadata type. Once this is done use a simple script to filter out the items from the managed package and finally use the list of filtered out items(usually the names) in your package.xml to retrieve the required components using force.com migration tool. Thanks.

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

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.