Sub topic 8
Sandbox templates: controlling which data is copied
This chapter assumes you know the four sandbox types and the difference between metadata (configuration and code) and data (records). It also assumes you can navigate Setup.
What a template does
A sandbox template is a saved list of objects whose records are copied into a sandbox. Metadata is always copied in full. A template only limits the data.
Templates apply to Partial Copy and Full sandboxes. Developer and Developer Pro sandboxes copy no production records, so there is nothing for a template to control.
| Sandbox type | Template use |
|---|---|
| Developer | Not applicable |
| Developer Pro | Not applicable |
| Partial Copy | Required to choose which data is sampled |
| Full | Optional, to copy only selected objects |
Why use one
- A Partial Copy sandbox has a fixed data limit. A template keeps the sample focused on the objects your testing needs.
- A Full sandbox with a template is smaller and often finishes copying faster.
- Smaller data sets are easier to reason about and expose less production data.
- The same template can be reused every time you create or refresh a sandbox, so the result is repeatable.
How templates fit into creation
Creating a template
- In Setup, enter
Sandbox Templatesin Quick Find and open it. - Click New Sandbox Template.
- Enter a name and a description. Describe the purpose, such as "QA regression: accounts, contacts, opportunities".
- Select the objects whose data you want to copy.
- Save the template.
When you select an object, Salesforce also selects objects it depends on through required relationships. For example, choosing Contact brings in Account, because a contact may need its parent account to be useful. Review the final list before you save.
Using a template
You pick the template during sandbox creation. For a Partial Copy sandbox the template choice is part of the data setup. For a Full sandbox you can choose a template or copy everything.
Templates are also offered when you refresh. If you edit a template, the change takes effect the next time a sandbox uses it. It does not alter a sandbox that already exists.
Common mistakes
- Expecting a template to shrink metadata. Templates never remove configuration or code.
- Forgetting dependencies. A sandbox with Opportunities but no Accounts is hard to test. Check the automatically selected related objects.
- Assuming a template fits every sandbox type. You cannot use one to add data to a Developer sandbox. Load that data yourself with a data tool or a post-copy script.
- Letting templates go stale. If your data model gains an object that testers need, add it to the template before the next refresh.
Exercise
Your team needs a QA sandbox that contains only Accounts, Contacts, and Opportunities from production. Which sandbox types can use a template to do this, and what does the template not change?
Show answer
Partial Copy and Full sandboxes can use a template. The template limits which object data is copied, but all metadata (configuration and code) is still copied in full. Developer and Developer Pro sandboxes copy no production records, so a template does not apply to them.