7

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.

Thanks.

7 Answers 7

6

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!

9

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

https://packagebuilder.herokuapp.com/

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

1
  • are you aware of any tool better than packagebuilder.herokuapp.com to generate package.xml automatically. Commented Nov 25, 2015 at 13:32
3

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.

3

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

https://marketplace.visualstudio.com/items?itemName=VignaeshRamA.sfdx-package-xml-generator

enter image description here

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

1

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.

0

See this Google Extension

https://chrome.google.com/webstore/detail/sfdc-magic-toolkit/kilgdoafhhpkloidoajmlfienjndfbfo

Please see this Extension this will help you alot.

0

You can get a package.xml by creating a Change Set of the components:

  • Create a Change Set of the components that you need in your package.xml

  • Use sfdx CLI at command line:

    sfdx force:mdapi:retrieve -s -r path\to\dir -p Name_Of_ChangeSet -u OrgAlias

  • This will retrieve a zip of the metadata, including a package.xml, to path\to\dir. -s tells it that it's a single package

  • Go to the dir that you specified, get the package.xml from the zip and throw the rest away

Thanks to Mohith Shrivastava for the solution here which I adapted for my needs:

https://medium.com/@mohitkumarsrivastav/auto-generate-package-xml-for-salesforce-application-development-deployment-e73eb53edf40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.