I want to create the package.xml base on a selection of components that a user check for example apex classes, apex triggers, then export that package or do something else.

I don't care about the programming language, but I would like to have a general idea of how to do that, or some ideas.



Here is what you need to do:

  1. You need the ability to fetch the metadata details from the org. If you want to do this in Apex, you might want to check out the Apex Wrapper Salesforce Metadata API.
  2. You could use the Salesforce REST APIs for Metadata and do this in javascript example (by creating a chrome extension?). You can check out the source code of this chrome extension "Salesforce Inspector" which effectively utilizes the metadata of the org to provide awesome time saving utlity.
  3. Not to forget you would also need to understand how does the package.xml look like for each of the selected component. This information is documented very well here.
  4. Once you know whats the metadata and how to fetch it, and how the package.xml looks like. It is only about putting these pieces together and automating the process.

    I remember discussing with someone reg. an utility wherein the developer could provide the start and enddates on a form. The page would display all the metadata (classes,objects,fields etc.) created/modified in the org during that time period. The user could then select any/all of the selected components and upon a button click a package.xml would be generated automatically. Are you working on something similar? Something like this(not sure if it exists already!) would be very helpful!

| improve this answer | |

There are already some open sourced tools for this task .One of them is as below


You can also use eclipse to the do this .In eclipse once you selected compoenents and fetch the package xml file is formed .

| improve this answer | |

I would highly suggest looking into the MavensMate API to accomplish any programmatically built package.xml. There is some great documentation on the API to point you in whatever direction you are looking to go with your project and examples for doing various operations.

The MavensMate plugin for SublimeText has a really nice UI for editing Package.xml's as well, and I highly recommend it as an IDE.

| improve this answer | |

There is an extention in VS Code that allows you to choose components and generate package.xml file using point and click

Salesforce Package.xml generator for VS Code


enter image description here

Affiliation : I am the developer of this free to use VS Code extension

| improve this answer | |

To grab a full package.xml use force-dev-tool, see: https://github.com/amtrack/force-dev-tool.

npm install --global force-dev-tool
force-dev-tool remote add mydev user pass --default
force-dev-tool fetch --progress
force-dev-tool package -a

You will now have a full src/package.xml.

| improve this answer | |

See this Google Extension


Please see this Extension this will help you alot.

| improve this answer | |

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.