Find your content:

Search form

You are here

Using sf:bulkRetrieve do not fetch metadata components associated with a managed package

 
Share

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


Attribution to: user1311813

Possible Suggestion/Solution #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


Attribution to: Subhojeet_Sfdc

Possible Suggestion/Solution #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.


Attribution to: Jason Lantz
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33064

My Block Status

My Block Content