Sub topic 2
What a Change Set Is and How It Moves
This chapter assumes you can work in Setup and know the difference between a production org and a sandbox. It also assumes you know metadata types such as custom objects, fields, flows and Apex classes. The previous chapter separated configuration (metadata) from records (data). This chapter builds on that split and defines the change set itself.
The definition
A change set is a named container of metadata components. You build it in one org, called the source org. You send it to a second org, called the target org. The target org's administrator reviews it and deploys it. Salesforce handles the packaging, transfer and deployment for you.
A change set has these properties:
- It holds metadata only. It never holds records such as accounts, invoices or users.
- It moves in one direction. A change set built in a sandbox and sent to production cannot be pulled back from production.
- It has two forms. The source org sees it as an outbound change set, and the target org sees it as an inbound change set.
- It is a list of component references, not a copy of your org. When you add
Invoice__cto a change set, you add that object definition. The change set does not add every field, page layout or record behind it unless you add those too.
You work with change sets in Setup. Outbound change sets are under Deploy > Outbound Change Sets, and inbound ones are under Deploy > Inbound Change Sets. You need the Deploy Change Sets permission in both orgs. To upload, you also need the Upload Change Sets permission in the source org.
Two views of one object
The same change set looks different in each org:
| Aspect | Outbound change set | Inbound change set |
|---|---|---|
| Where it appears | Source org | Target org |
| Who creates it | You, by adding components | Salesforce, when an upload arrives |
| Can you edit components? | Yes, until you upload it | No |
| What you can do | Add components, view dependencies, upload, clone | View contents, validate, deploy, delete |
The most common surprise is that an uploaded change set is locked. If you find a missing component after uploading, you cannot add it to the same change set. Clone the change set, add the component to the clone, and upload the clone under a new name. The target org then holds two inbound change sets.
How a change set moves
A change set goes through these steps:
- In the source org, you create an outbound change set and give it a name and description.
- You add components, either one type at a time or by listing dependencies.
- You upload it to a target org that has an authorized deployment connection to the source.
- Salesforce copies the metadata into the target org, where it appears as an inbound change set.
- An administrator in the target org validates it, optionally, and then deploys it.
- Salesforce writes the components into the target org and reports the status.
The arrow from the inbound change set straight to the deploy step is deliberate. Validation is optional. You can deploy without validating first, though validating is usually the safer choice. A later chapter covers validation in detail.
What happens to existing components
Deployment follows two rules, and they apply to every component in the change set:
- If the target org has no component with the same type and API name, Salesforce creates it.
- If the target org already has one, Salesforce overwrites it with the version from the change set.
Overwriting is the part to be careful about. Suppose someone edited a validation rule directly in production and the same rule is in your change set. Deployment replaces the production edit with your sandbox version, without a merge and without a warning about the difference. Change sets give you no built-in way to compare the two versions before deploying.
Change sets also cannot remove components. If you deleted a field in the sandbox, adding nothing to the change set leaves that field in production. You must delete it there by hand.
A deployment is also all or nothing. If one component fails, or one Apex test fails when tests are required, Salesforce rolls the whole deployment back. The target org stays as it was before you started.
Seeing what a change set contains
The change set interface shows components as a list grouped by type. This is the same information a Salesforce metadata manifest holds. A manifest is an XML file named package.xml. It lists metadata by type and name, and the Salesforce CLI and the Metadata API use it. You never see a package.xml when you work with change sets, but thinking in its terms helps. A change set is, in effect, a manifest that Salesforce also fills with the component contents.
This manifest describes one custom object and two Apex classes:
<?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>Each <types> block names one metadata type in <name> and lists the components of that type under <members>. The <version> element is the API version used to interpret the metadata. In the change set UI, the same list appears as "Custom Object: Invoice" and "Apex Class: InvoiceService".
You can retrieve those components from a sandbox with the Salesforce CLI. This is a way to check what the source org holds while you plan a change set:
sf project retrieve start --manifest manifest/package.xml --target-org MySandboxUse the manifest above, saved at manifest/package.xml in a Salesforce DX project. --target-org names the org the command runs against. In this command, that is your source sandbox, not the deployment target. The files land in your local project, where you can read them or compare them with a retrieve from production. The CLI is a separate tool from change sets. Here it only lets you inspect the same kind of component list.
What is and is not in a change set
Adding a component adds its definition, not everything related to it. Some examples:
- Adding a custom object includes the object and its standard configuration, but custom fields, page layouts and record types are separate components. Whether they come along depends on the component and what you add.
- Adding a flow adds the flow version you select. It does not add the Apex classes, objects or fields it uses.
- Adding an Apex class adds the code. The classes it calls are separate components.
The change set tool can list dependent components for you. You pick the ones to include. A later chapter covers this step, because missing dependencies are the most common deployment failure.
Some metadata types cannot be added to a change set at all. Other components can be added but need manual configuration after deployment. Both topics have their own chapters. For now, treat the Add page in the change set as the authority. If a type is not in its component type list, a change set cannot move it.
The shape of a good change set
Change sets reward habits that keep each deployment small and traceable:
- Name each change set after its purpose and date, for example
Invoice_Object_2026-11. Names are your only record of what was moved and why. - Use the description field to note the work item or release it belongs to.
- Keep one change set per feature when you can. A change set that mixes ten unrelated features cannot be partly deployed. One failure rolls back all ten.
- Keep your own list of what you added. Change sets show you components, but they do not give you a history of changes in the source org.
Summary of the model
A change set is a one-way, metadata-only package. The source org builds it as an outbound change set. The target org receives it as an inbound change set, and deployment either creates or overwrites each component. The next chapter covers which orgs can exchange change sets, which determines where you can send one.
Exercise
You uploaded a change set to production and then realized you forgot one custom field. The field exists in the sandbox. What do you do, and what happens to the first change set in production?
Show answer
You cannot edit an uploaded change set. Clone the outbound change set in the sandbox, add the missing custom field to the clone, and upload the clone under a new name. The first change set stays in production as an inbound change set. You can ignore it or delete it, and you deploy only the new one so the components are not deployed twice.
Exercise
A field was deleted in the sandbox, and you deploy a change set that contains the rest of the object's configuration. Does the field disappear from production? Why or why not?
Show answer
No. Change sets cannot delete components. Deployment only creates or overwrites components that are in the change set. The field must be deleted in production by hand.
Exercise
Why does one failing Apex test or one failing component stop a whole deployment from changing the target org, and what does this mean for how you group components?
Show answer
Change set deployments are all or nothing. If any part fails, Salesforce rolls back everything and the target org stays unchanged. Group related components that belong to one feature into a change set. Avoid mixing unrelated work, so one problem does not block every other change.