Sub topic 8
Choosing the right org for the task
This chapter assumes you know the four sandbox types and how scratch orgs work. It also assumes you can use the Salesforce CLI and Git. Here you will turn that knowledge into a decision you can make for a given task.
Compare on four dimensions
Each org type trades off the same four things:
- Data: how much production data the org holds.
- Configuration fidelity: how closely its metadata matches production.
- Lifespan: how long it lasts and how often you can reset it.
- Cost and limits: how many you can have and how long they take to create.
| Org type | Data | Configuration | Refresh or lifespan | Typical use |
|---|---|---|---|---|
| Developer sandbox | None. 200 MB data storage limit | Copy of production metadata | Refresh once per day | Individual development, unit tests |
| Developer Pro sandbox | None. 1 GB data storage limit | Copy of production metadata | Refresh once per day | Larger test data sets, integration work |
| Partial Copy sandbox | Sample data chosen by a sandbox template, up to 5 GB | Copy of production metadata | Refresh every 5 days | User acceptance testing, QA |
| Full sandbox | Complete copy of production data | Copy of production metadata | Refresh every 29 days | Performance tests, staging, training |
| Scratch org | Only what you seed | Built from a definition file and your source | 1 to 30 days, default 7 | Feature work, CI, package development |
Check the current limits for your edition. Allocations vary by contract.
Ask the questions in order
Work through these questions from top to bottom. The first one that applies usually decides the answer.
- Do you need production data volumes or real data relationships? Use a Full sandbox for performance and load tests. Use a Partial Copy sandbox if a representative sample is enough.
- Is the work an isolated feature that your source code can fully describe? Use a scratch org. It starts clean, so your repository must contain everything the feature needs.
- Do you depend on production configuration that is not in source control? Use a Developer or Developer Pro sandbox. It starts as a copy of production metadata, so it already has that configuration.
- Do you need more than 200 MB of test data? Choose Developer Pro, or seed a scratch org with a smaller data set.
Worked examples
A new Lightning component with unit tests. Everything lives in the repository, and no production data is needed. A scratch org gives you a clean environment and source tracking, so you can push and pull changes.
Fixing a bug in a flow that depends on years of configuration. The bug only appears with production's real setup, and rebuilding that setup in source would take days. Create a Developer sandbox. It copies production metadata, so you can reproduce the problem right away.
Load testing a nightly batch job. The job's behavior depends on millions of records. Only a Full sandbox holds that volume. Plan around its 29-day refresh interval, so schedule the test before the next refresh window, not after.
Business users signing off on a release. They need realistic records but not all of them. A Partial Copy sandbox with a template that selects the relevant objects is enough.
Common errors in this decision
- Using a Full sandbox for daily development. It refreshes only every 29 days, so a broken or polluted copy stays that way. Reserve it for work that needs its data.
- Treating a scratch org like a sandbox. It does not inherit production configuration. If the feature works there only because you set something by hand, the setting must go into the definition file or source before you rely on the result.
- Testing in a Developer sandbox with no data. Tests that pass with empty tables can fail against real volumes. Seed data deliberately, or move up to Partial Copy.
- Ignoring data protection. Partial Copy and Full sandboxes carry production data. Mask sensitive fields before developers get access.
Exercise
Your team must reproduce a defect that only occurs with 3 million Account records and a long-standing set of production validation rules. Which org type fits, and why not a scratch org or a Developer sandbox?
Show answer
A Full sandbox. It is the only type that holds a complete copy of production data, so it supports the 3 million records, and it copies production configuration. A scratch org starts empty and has only the configuration in your source and definition file. A Developer sandbox copies metadata but holds only 200 MB of data, so it cannot hold that volume.