Sub topic 2
What a change set is and how it moves
This chapter assumes you can work in Setup, know the difference between a production org and a sandbox, and recognize metadata types such as custom objects, fields, flows, and Apex classes. You also need a user with the Deploy Change Sets permission to follow along in your own orgs.
What a change set is
A change set is a named bundle of metadata components that you build in one org and send to another. Components are things like a custom object, a field, a flow, or an Apex class. A change set holds only the list of components and their definitions. It never holds records such as accounts, contacts, or opportunities.
The org where you build the bundle is the source org. The org that receives it is the target org. The two orgs must be related, for example a sandbox and its production org. Later chapters cover which pairs are allowed and how to authorize them.
One change set, two views
The same bundle appears under two different names, depending on which org you are looking at.
| View | Where it appears | What you can do |
|---|---|---|
| Outbound change set | Source org | Add components, edit the list, upload |
| Inbound change set | Target org | Review contents, validate, deploy |
An outbound change set can be edited until you upload it. After the upload, it is locked. To change the contents, you clone it into a new change set and upload that one instead.
How it moves
A change set travels in one direction and in distinct steps. Nothing reaches the target org until you deploy.
- You create an outbound change set in the source org and add components.
- You upload it to the target org over a deployment connection.
- The target org lists it as an inbound change set.
- An administrator there validates it, then deploys it.
Uploading only transfers the bundle. Deploying is the step that creates or updates components in the target org.
A change set is a component list
A change set is similar to a manifest file used by developer tools. A package.xml manifest lists components by metadata type and name, which is the same kind of list a change set holds.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Invoice__c</members>
<name>CustomObject</name>
</types>
<types>
<members>InvoiceService</members>
<members>InvoiceServiceTest</members>
<name>ApexClass</name>
</types>
<version>61.0</version>
</Package>This manifest names one custom object and two Apex classes. If you put these three components in a change set, the contents would be the same.
You can use the manifest to check the source org before you build. This command retrieves the listed components from a sandbox, so you can compare them with what the change set will contain.
sf project retrieve start --manifest manifest/package.xml --target-org MySandboxCommon errors at this stage
- Expecting data to move. A change set that includes
Invoice__ccreates the object definition in the target org. It does not copy any invoice records. - Editing after upload. An uploaded change set is read-only. Clone it to make changes.
- Assuming deployment is automatic. Upload only delivers the bundle. Nothing changes in the target org until someone deploys the inbound change set.
- Mismatched orgs. If the two orgs are not related, the target will not appear as an upload destination.
Exercise
You upload a change set containing the custom object Invoice__c from a sandbox to production, then deploy it. The sandbox has 500 invoice records. How many invoice records exist in production because of this deployment, and why?
Show answer
Zero. A change set moves metadata only, so it creates the Invoice__c object definition in production but copies none of the records. Records must be loaded separately with a data tool.