Create Change Set using package.xml

Hello Folks!
Today I would like to show you, how to generate Change Set metadata content, based on package.xml.
Let’s assume, that you have a repository with all changes that you made on the environment, but the client’s politics requires Change Sets to move content from sandbox to production. We have a problem! You have a lot of apex classes, objects, LWC components, etc. and now you need to select all of them in Change Sets UI. It can be painful, but no worries. We have a solution for it!
Let’s begin!

Step 1: Create Outbound Change Set

Before we fill our ChangeSet with metadata content, we need to create it.
Go to your sandbox, Setup > Outbound Change Sets, and create a new one.
Copy your Change Set’s name, will be needed later.

Create Change Set
Created ChangeSet

Step 2: Adjust your code and package.xml

Go to your repository, or wherever you have org’s metadata, and modify the package.xml file with the following line [3] and [4] (optional)

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>TestChangeSet</fullName>
    <description>Change Set Description</description>
    <types>
        <members>TestApexClass</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>testLwcComponent</members>
        <name>LightningComponentBundle</name>
    </types>
    <version>49.0</version>
</Package>
Code structure
Code structure

Important! Create .zip with all changes.

Zipped Change Set
Zipped ChangeSet

Step 3: Log in to Workbench

Firstly go to Workbench and log in to the sandbox where you created ChangeSet in the first step.

Secondly, go to migration > Deploy and upload your .zip file created in step 2 and check Auto Update Package.
Finally, Click Next and Deploy.

Upload Change Set via Workbench
Upload ChangeSet via Workbench
Successfully Update
Successfully Update

Step 4: Enjoy your Change Set with uploaded metadata!

Uploaded Change Set
Uploaded Change Set

Consideration!

  • Make sure that your ChangeSet doesn’t exceed approximately 5,000 components.
  • Change Set’s names are not unique! Be sure that during the upload with workbench you have only one Change Set with the full name used in package.xml
  • After you upload a ChangeSet, its status becomes closed, and you can’t make changes to its component

Was it helpful? Check out our other great posts here.

Resources

  • https://help.salesforce.com/articleView?id=changesets.htm&type=5
  • https://help.salesforce.com/articleView?id=changesets_about_outbound.htm&type=5
5 13 votes
Article Rating
Subscribe
Notify of
guest
4 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Renan Rocha
Renan Rocha
1 year ago

Hello Piotr, first thanks for sharing.

Unfortunately for me this solution does not work, I’m getting the result: “More than 1 developer package named ‘TestDeployPack’ exists in this organization. Please rename one of packages so that it has a unique name.”

Tried creating the zip with a folder and without it, also tried changing the API to 49 like your example, nothing seems to work on my end.

Manu
Manu
1 year ago

Typo at closing tag for description in package.xml

Close Menu
4
0
Would love your thoughts, please comment.x
()
x