Sub topic 3
Which orgs can exchange change sets
This chapter assumes you can navigate Setup and know the difference between a production org and a sandbox. It also assumes you know what a change set is from the previous chapter. Here you learn which orgs can send and receive change sets. That decides your deployment paths before you build anything.
The rule: one production family
A change set can only travel between orgs that belong to the same production org. This group is called the production org's family. The family contains:
- The production org itself.
- Every sandbox created from that production org.
Salesforce does not let you pick any two orgs and connect them. The relationship comes from how the orgs were created. A sandbox is created from one production org, so the two are related for as long as the sandbox exists.
Two orgs can exchange change sets when both are in the family. That covers three kinds of pairs:
- A sandbox and its production org, in either direction.
- Two sandboxes created from the same production org.
- Any other family pair, as long as the direction is authorized (see the next chapter).
Pairs that work and pairs that do not
The table lists common combinations and whether change sets can connect them.
| Source | Target | Change sets supported? |
|---|---|---|
| Sandbox | Its production org | Yes |
| Production org | One of its sandboxes | Yes |
| Sandbox | Another sandbox of the same production org | Yes |
| Sandbox | Sandbox of a different production org | No |
| Production org | A different production org | No |
| Developer Edition org | Production or sandbox | No |
| Trial org | Production or sandbox | No |
| Scratch org | Any org | No |
Two points in the table surprise people.
First, a Developer Edition org is not part of a production family, even if you use it to prototype for your company's production org. It has no parent production org. To move its work, use another tool such as the Salesforce CLI or a package. The last chapter of this tutorial covers those tools.
Second, scratch orgs belong to the source-driven development model. They are created from a Dev Hub org and are meant to be thrown away. They have no deployment connections, so change sets are not an option for them.
Why the family model exists
The family model protects production. A change set carries metadata that can alter how an org behaves, so Salesforce limits where it can come from. An unrelated org cannot push metadata into your production org, and a sandbox cannot push into another company's org. The sandbox-to-production relationship is established by Salesforce when the sandbox is created, so you do not have to prove it yourself.
Choosing a deployment path
Within a family you decide the route. Two patterns are common.
Direct path
A single sandbox deploys to production.
- An administrator builds a change in the sandbox.
- The administrator uploads it to production.
- Someone validates and deploys it.
This suits small teams, but it skips any separate testing stage.
Staged path
Changes move through several sandboxes in order, for example Dev, then QA, then UAT, then production. Each hop is a separate change set. The same components are usually uploaded more than once, once per hop, and each upload creates a new change set that you must build or clone.
Production can also send change sets back down to a sandbox. This is useful when a fix was made directly in production and you want to bring it into the sandboxes. Many teams prefer to refresh the sandbox instead, because a refresh copies all production metadata at once. A refresh also overwrites unfinished work in that sandbox, so it is not always the right choice.
Connections are directional
Being in the same family means two orgs can be connected, but a connection must also permit the direction of travel. In Setup, the Deployment Settings page lists the orgs in your family. Each one has an authorization setting for inbound changes. A target org must allow inbound changes from the source org before the source can upload to it.
So "connected" and "authorized" are separate ideas:
- Connected: the orgs are in the same family, so they appear in each other's Deployment Settings list.
- Authorized: the target has allowed inbound changes from that particular source.
A sandbox might show up in the list of a production org but still not be able to receive from production, if inbound changes are not allowed for it. The next chapter shows how to set this authorization.
Checking what kind of org you are in
Before you plan a path, confirm what each org is. In Setup you can look at Company Information. From the command line, you can query the Organization object with the Salesforce CLI:
sf data query \
--query "SELECT Name, IsSandbox, OrganizationType, InstanceName FROM Organization" \
--target-org MySandboxThe IsSandbox field is true for a sandbox and false for production. OrganizationType shows the edition, such as Enterprise Edition or Developer Edition. A result of Developer Edition tells you at once that this org is outside any production family and cannot take part in change sets.
Gotchas
Sandbox refresh and deletion
A refreshed sandbox keeps its place in the family, so you do not have to create the connection again. The authorization settings usually need a second look after a refresh, because a refresh recreates the sandbox from production. Check Deployment Settings after each refresh rather than assuming that it is as you left it.
A deleted sandbox disappears from the list. Any change sets already uploaded to or from it are gone with it. If you need a record of what was deployed, keep it somewhere else, such as a manifest file or version control.
Release timing
Salesforce releases three times a year. During the weeks around a release, some sandboxes are upgraded before production, so the family briefly runs on two versions. Deploying metadata from an org on a newer version into an org on an older one can fail or be blocked, because the older org may not recognize new fields or features. If a path that normally works suddenly stops, check the version of each org. In Setup, the Salesforce release notes and the Trust site show the schedule for your instance.
Edition and feature differences
The family model only makes the connection possible. The target org must also support the features in your components. If your sandbox is on an edition with a feature that production lacks, a component relying on it will fail at validation even though the orgs are connected. Chapter 13 on troubleshooting covers such errors.
Permissions
A connection does not give anyone rights. You need the Deploy Change Sets permission in the target org to validate and deploy, and the Upload Outbound Change Sets permission in the source org to send one. Both are separate from the family relationship.
Planning checklist
Before you build a change set, confirm these points:
- Both orgs belong to the same production family.
- The target org allows inbound changes from the source org.
- Your user has the right permissions in each org.
- The two orgs run compatible Salesforce versions.
- You have chosen a direct or staged path, and the intermediate sandboxes are up to date.
Exercise
Your company has a production org with two sandboxes, Dev and QA. A contractor built a prototype in their own Developer Edition org and wants to send it to your QA sandbox using a change set. Is this possible? What would you suggest instead?
Show answer
No. A Developer Edition org is not part of your production org's family, so it cannot be connected to QA through change sets. The contractor can instead use a tool that does not depend on the family relationship, such as the Salesforce CLI with a package.xml manifest (retrieve from the Developer Edition org, deploy to QA), or an unlocked package. Another option is to rebuild the prototype by hand in the Dev sandbox, then use a change set from Dev to QA.
Exercise
Dev and QA sandboxes are both created from your production org. In Deployment Settings, you see QA listed in Dev's connections, but an upload from Dev to QA still fails with a message that the target does not accept changes. What is the likely cause and where do you fix it?
Show answer
The orgs are connected because they are in the same family, but QA is not authorized to accept inbound changes from Dev. In QA, open Setup, go to Deployment Settings, edit the entry for Dev, and allow inbound changes. Then retry the upload.