Salesforce DevOps Course Module 2: Environments & Sandboxes Complete Guide 2026
Complete Guide
๐ Course Progress — Module 2 of 15
Intro
Sandboxes
Change Sets
Metadata API
Git Basics
SFDX & CLI
Scratch Orgs
Packages
DevOps Center
Deploy Strategy
GitHub Actions
Advanced CI/CD
Unlocked Pkg
Enterprise
Capstone
๐ What You Will Learn in This Module
๐ Full Course Navigation
๐ Section 1 — What are Salesforce Environments?
Understanding the different org types in your Salesforce ecosystem
Think of environments like the stages a new product goes through before it reaches customers: prototype lab → quality control → safety testing → store shelf. Each stage has a specific job.
| Environment | Type | Who Uses It | Purpose |
|---|---|---|---|
| Production | Live org | Real customers, end users | The live business system — never test here |
| Full Sandbox | Sandbox | Business users, QA leads | UAT — complete production clone |
| Partial Copy Sandbox | Sandbox | QA team | Integration and regression testing with sample data |
| Developer Pro Sandbox | Sandbox | Developers, admins | Development with larger datasets |
| Developer Sandbox | Sandbox | Individual developers | Daily development, no data needed |
| Scratch Org | Temporary org | Developers | Isolated feature development (covered in M7) |
Production is where real customers do real business. A mistake there costs real money and damages real relationships. Everything happens in environments first — only proven, tested, approved changes reach production.
- Salesforce production and all its sandboxes are separate orgs — changes in one do not automatically appear in another
- Sandboxes are always connected to their parent production org
- Every Salesforce edition includes at least one Developer sandbox
- Full and Partial Copy sandboxes require higher Salesforce editions (Enterprise+)
๐️ Section 2 — The 4 Salesforce Sandbox Types
Deep dive into every sandbox type — storage, data, refresh, and use cases
How many: You can create multiple Developer sandboxes — one per developer is the best practice.
Limitation: Only 200MB — not suitable for testing with large data volumes or realistic data scenarios.
Difference from Developer: 5x more storage. Same behavior otherwise — no production data copied.
When to use: When a Developer sandbox is running out of storage or when testing requires more than a few hundred records.
Key feature: Sandbox Template controls WHICH records are copied. You define: "Give me 500 Accounts with their related Contacts, 1,000 Opportunities, and all Product records."
Limitation: 5-day refresh interval means you cannot refresh it daily. Max 10,000 records per object without a template.
Critical difference: Emails are suppressed by default (so you don't accidentally email real customers). Login URL is test.salesforce.com. Usernames are suffixed with the sandbox name.
Limitation: 29-day refresh interval and most expensive. Takes hours to create (copying all production data). Most teams have only one Full sandbox.
| Feature | ๐ข Developer | ๐ต Dev Pro | ๐ก Partial | ๐ด Full |
|---|---|---|---|---|
| Data Storage | 200MB | 1GB | 5GB | = Production |
| File Storage | 200MB | 1GB | 5GB | = Production |
| Production Data? | ❌ No | ❌ No | ✅ Sample | ✅ All |
| Sandbox Template? | ❌ No | ❌ No | ✅ Required | ❌ Not needed |
| Refresh Interval | 1 day | 1 day | 5 days | 29 days |
| Creation Speed | Minutes | Minutes | Hours | Hours–Days |
| Cost | Included | Add-on | Add-on | Most expensive |
| Best For | Daily dev | Larger dev | QA testing | UAT/Training |
๐ค Section 3 — Which Sandbox to Use When?
The decision guide every Salesforce professional needs
- ✅ Writing or modifying Apex classes, triggers, or test classes
- ✅ Building LWC components
- ✅ Creating or modifying Flows, Process Builder, validation rules
- ✅ Adding custom fields, objects, or page layouts
- ✅ Configuring approval processes or email templates
- ✅ You need a quick isolated environment to test something fast
- ✅ You are learning — every developer needs their own space to experiment
- ✅ The QA team is testing a feature and needs realistic data
- ✅ Testing reports, dashboards, or analytics with real-looking data
- ✅ Integration testing where data relationships matter (Account → Contact → Opportunity)
- ✅ Performance testing with a sample of real volume
- ✅ QA regression testing before production releases
- ✅ Business users are doing User Acceptance Testing (UAT) — they need real data
- ✅ Full performance testing with production-level data volumes
- ✅ Training new employees on real data without risking production
- ✅ Testing integrations with external systems using complete production datasets
- ✅ Final sign-off before a major release
| Task | Best Sandbox | Why |
|---|---|---|
| Write an Apex class | ๐ข Developer | No data needed, fast refresh |
| Build a complex Flow | ๐ข Developer | Declarative work, seed your own data |
| Test batch job on 50K records | ๐ต Developer Pro | More storage for larger test data |
| QA test a new feature | ๐ก Partial Copy | Realistic sample data for testing |
| Business UAT sign-off | ๐ด Full | Real data, real environment for approval |
| Train new sales reps | ๐ด Full | Real data without affecting production |
| Isolated feature dev (SFDX) | ๐ฌ Scratch Org | Temporary, consistent, no conflicts |
๐ Section 4 — Sandbox Refresh — Everything You Need to Know
What happens, what you lose, what is kept, and how to prepare
| Item | Developer | Partial Copy | Full |
|---|---|---|---|
| All Apex code | ✅ Yes | ✅ Yes | ✅ Yes |
| All LWC/Aura components | ✅ Yes | ✅ Yes | ✅ Yes |
| Custom objects & fields | ✅ Yes | ✅ Yes | ✅ Yes |
| Flows, validation rules | ✅ Yes | ✅ Yes | ✅ Yes |
| Profiles & permission sets | ✅ Yes | ✅ Yes | ✅ Yes |
| Users | ✅ Yes | ✅ Yes | ✅ Yes |
| Data records | ❌ No | ✅ Sample | ✅ All |
| File attachments | ❌ No | ❌ No | ✅ Yes |
- All sandbox-specific customizations NOT in production are permanently deleted
- Any Apex class, LWC, Flow, or field you built in the sandbox but never deployed to production
- All test data you manually created in the sandbox
- All user passwords — everyone must reset passwords after refresh
- All Named Credential configurations pointing to test endpoints
- All custom settings configured specifically for the sandbox
- All scheduled jobs running in the sandbox
⚠️ There is NO way to recover anything lost in a sandbox refresh. Backup what matters before refreshing!
| Step | Action | Why |
|---|---|---|
| 1 | Deploy all completed features to production first | Anything in sandbox but not production will be lost |
| 2 | Export important test data you want to keep | All sandbox data is wiped during refresh |
| 3 | Document all sandbox-specific configurations | Named credentials, custom settings, email relay settings |
| 4 | Notify all sandbox users | Their passwords will reset, work in progress may be lost |
| 5 | Save any test scripts or setup scripts | You will need to re-run them after refresh |
- ✅ Log in to sandbox at test.salesforce.com (not login.salesforce.com)
- ✅ Username format: youremail@company.com.sandboxname
- ✅ Reset your password via "Forgot Password"
- ✅ Reconfigure Named Credentials to point to test endpoints
- ✅ Reconfigure email deliverability settings
- ✅ Re-run your Test Data Factory to seed test data
- ✅ Notify all team members sandbox is ready
๐ Section 5 — Sandbox Templates
Control exactly what data goes into your Partial Copy sandbox
Without a template, Salesforce randomly selects up to 10,000 records per object — you have no control over which records are copied or whether related records come together. With a template, you get exactly the data you need for meaningful testing.
With a template: You say "give me 500 Accounts AND their related Contacts AND their related Opportunities." Salesforce maintains the data relationships — testers have realistic, connected data.
| Step | Action | Location |
|---|---|---|
| 1 | Go to Sandbox Templates | Production Setup → Sandboxes → Sandbox Templates → New |
| 2 | Name your template | "QA Testing Template" or "Performance Template" |
| 3 | Select objects to include | Check the objects you need (Account, Contact, Opportunity, etc.) |
| 4 | Set record limits per object | Max records to include (e.g., 500 Accounts, 2000 Contacts) |
| 5 | Use template on refresh | When creating/refreshing Partial Copy, select this template |
| Object | Records | Why |
|---|---|---|
| Account | 500 | Enough for realistic testing across all territories |
| Contact | 2,000 | Multiple contacts per account |
| Opportunity | 1,000 | Test pipeline reports and dashboards |
| Product2 | All | Need all products for quoting tests |
| Pricebook2 | All | All pricelists for multi-currency testing |
| Order | 500 | Test order management flows |
| Case | 300 | Test service cloud workflows |
Total: ~4,800 records — well within the 5GB Partial Copy limit. All records maintain their relationships — testers have realistic data that mirrors production behavior.
- Templates are only for Partial Copy sandboxes — Full sandboxes copy everything
- You can create multiple templates for different testing needs
- Template configuration does not copy to the sandbox — only the data it selects
- Salesforce respects object relationships when copying — related records are included
- Custom objects can also be included in templates
๐ฑ Section 6 — Sandbox Seeding
How to populate Developer sandboxes with test data
Steps:
- Export data from production using Data Loader (as CSV)
- Clean up the CSV (remove IDs, fix relationships)
- Login to sandbox using Data Loader with test.salesforce.com endpoint
- Import CSV files in dependency order (Account → Contact → Opportunity)
Steps: Login with Salesforce OAuth → Choose object → Upload CSV → Map columns → Import. Done in 5 minutes.
| Practice | Why |
|---|---|
| Use a Test Data Factory class | Reusable, consistent, version-controlled |
| Seed in dependency order | Account first, then Contact, then Opportunity |
| Use realistic but fake data | Real email addresses risk sending test emails to real people |
| Include edge cases | Empty fields, max length values, special characters |
| Document your seed script | New team members can set up in minutes |
๐ง Section 7 — Email Deliverability in Sandboxes
Prevent accidentally emailing real customers from your sandbox
Imagine a Flow that sends "Your order has been confirmed" — if running in a sandbox during testing, it will email actual customers with wrong order information. This is a serious issue that needs to be configured correctly immediately after every sandbox refresh.
| Setting | What Gets Sent | Use Case |
|---|---|---|
| No Access | Nothing at all | Fully isolated — no emails of any kind |
| System Email Only | System emails (password resets, admin notifications) | Default sandbox setting — safest for development |
| All Email | All emails including workflow and template emails | Use only with test data AND an email relay |
Setup: Setup → Email Relay Activation → Add your internal test email address (e.g., sandbox-emails@xyzcompany.com). Now when a workflow sends "Your Quote is Ready" to customer@realcompany.com, it actually goes to sandbox-emails@xyzcompany.com — where your team can verify it without the customer ever seeing it.
- Setting deliverability to "All Email" without an Email Relay after a Full sandbox refresh
- Running a test that triggers an email workflow — 500 customers receive a test email
- This has happened to real companies and caused serious trust issues with customers
- Always check email deliverability settings immediately after every sandbox refresh
๐บ️ Section 8 — Building Your Environment Strategy
How to design the right environment pipeline for your team
Build & Unit Test
QA Testing
Business Approval
Live Customers
| Tier | Sandbox Type | Owner | Purpose | Gate to Next |
|---|---|---|---|---|
| ๐ข Development | Developer (1 per dev) | Developer | Write code, unit test | All Apex tests pass, code review done |
| ๐งช QA | Partial Copy | QA team | Regression, integration tests | QA sign-off, all test cases pass |
| ✅ UAT | Full Sandbox | Business users | User acceptance, final validation | Business sign-off from stakeholder |
| ๐ Production | Production org | Admin/Release manager | Live customers | Scheduled release window |
Build & Test
Deploy after validation
- Changes always flow forward — Dev → QA → UAT → Production. Never backward except through the pipeline
- Never skip a tier — if something goes straight from Dev to Production, the QA and UAT catches are missed
- Each environment should be refreshed on a regular schedule to stay in sync with production
- Document who owns each environment and who can approve promotions
๐ฌ Section 9 — Sandbox vs Scratch Org
Understanding when to use each type of development environment
Scratch Orgs are covered in depth in Module 7 — this section gives you the conceptual foundation.
| Feature | ๐️ Sandbox | ๐ฌ Scratch Org |
|---|---|---|
| Lifespan | Permanent (until refreshed) | Maximum 30 days |
| Created from | Production org (copy) | Definition file (JSON) |
| Production data | Partial or Full copy | No production data |
| Version control | Limited integration | Fully source-driven |
| Creation time | Minutes to hours | 5 minutes |
| Environment consistency | Can drift from production | Always identical (same definition) |
| Cost | Included with license | Requires Dev Hub org |
| Multiple at once | Limited (purchased) | 40 active simultaneously |
| Best for | QA, UAT, training | Feature development, CI/CD |
| Required knowledge | Basic Salesforce | SFDX CLI, Git |
| Situation | Use |
|---|---|
| QA team needs to test a feature with real data | ๐️ Partial Copy Sandbox |
| Business users doing UAT sign-off | ๐️ Full Sandbox |
| Training new employees | ๐️ Full Sandbox |
| Developer building a new feature (SFDX) | ๐ฌ Scratch Org |
| CI/CD pipeline needs a clean environment | ๐ฌ Scratch Org |
| Quick fix, no SFDX set up yet | ๐️ Developer Sandbox |
๐ข Section 10 — XYZ Company Environment Setup
See exactly how a real team structures their Salesforce environments
| Environment | Type | Owner | Purpose | Refresh Schedule |
|---|---|---|---|---|
| Production | Live org | IT Manager | Real customers, live operations | Never refreshed |
| UAT Sandbox | Full | Meera (Admin) | Business sign-off before releases | Before major releases |
| QA Sandbox | Partial Copy | Kavya (QA Lead) | QA regression and integration testing | Monthly |
| Anant-Dev | Developer | Anant (Dev) | Apex, LWC, Agentforce development | When needed |
| Raj-Dev | Developer | Raj (Dev) | Integration and API development | When needed |
| Priya-Dev | Developer | Priya (Dev) | Flow and declarative development | When needed |
Builds Feature
Kavya Tests
Business Approves
Every Tuesday
Every Tuesday is XYZ Company's release day. Changes that have passed QA and UAT by Monday are deployed every Tuesday morning at 9 AM IST — a regular, predictable release cadence.
- ๐ด Never make changes directly in production — everything goes through Dev → QA → UAT → Prod
- ๐ก QA sandbox is refreshed every 1st of the month — everyone knows when the refresh is coming
- ๐ข Developer sandboxes are each developer's responsibility — refresh when you need a clean slate
- ๐ง Email deliverability on all sandboxes is "System Email Only" — email relay configured on QA and UAT
- ๐ Pre-refresh checklist is mandatory — no sandbox is refreshed without sign-off from the owner
⚠️ Section 11 — Common Sandbox Mistakes to Avoid
Learn from others' mistakes before making your own
- What happens: Developer refreshes their sandbox, unknowingly wiping 3 weeks of work that was never deployed to production
- The fix: Always run the pre-refresh checklist. Check what is in the sandbox that is not in production. Deploy completed work first.
- What happens: Developer A deploys a change. Developer B refreshes the page and sees the change — now they are accidentally building on top of each other. One person saves a component and overwrites the other's work.
- The fix: One sandbox per developer. They are cheap (included with licenses) and prevent all conflicts.
- What happens: QA sandbox is refreshed. The Named Credential for Business Central is now pointing to production BC endpoint. QA tests create real orders in the production ERP system.
- The fix: Post-refresh checklist must include reconfiguring all Named Credentials and Remote Site Settings to point to test/sandbox endpoints.
- What happens: QA team runs a test that triggers a "Quote Approved" email workflow. 200 customers receive a fake "your quote is approved" email from the company's real email address.
- The fix: Always configure email relay on QA and UAT sandboxes before enabling "All Email" deliverability. Never use "All Email" without a relay when real customer data is present.
- What happens: Team thinks "if production breaks, we can restore from the Full sandbox." Not true — Full sandbox does not automatically stay in sync with production. After its 29-day refresh, it may be weeks out of date.
- The fix: Use Salesforce Backup & Restore or a third-party backup tool for production backups. Sandboxes are development environments, not backup systems.
๐ Section 12 — Module 2 Quiz
Test everything you learned before moving to Module 3
๐ง Module 2 Knowledge Check — 10 Questions
๐ Module 2 Summary — Key Takeaways
Everything you mastered in this module
- ✅ Salesforce has 6 environment types — each with a specific purpose in the development pipeline
- ✅ 4 sandbox types: Developer (200MB), Developer Pro (1GB), Partial Copy (5GB, sample data), Full (complete clone)
- ✅ Sandbox refresh completely wipes and recreates from production — sandbox-only changes are permanently lost
- ✅ Always run pre-refresh and post-refresh checklists to avoid losing work or misconfiguring the environment
- ✅ Sandbox Templates control which records are copied into a Partial Copy sandbox — maintain data relationships
- ✅ Sandbox seeding populates Developer sandboxes using Data Loader, Dataloader.io, or a Test Data Factory class
- ✅ Email deliverability defaults to System Email Only — always configure an Email Relay before enabling All Email
- ✅ Standard 4-tier strategy: Dev → QA (Partial Copy) → UAT (Full) → Production
- ✅ Sandboxes = persistent, production copies for QA/UAT. Scratch Orgs = temporary, source-driven for development
➡️ Next: Module 3 — Change Sets Mastery
Deep dive into Change Sets — the full deployment workflow, validate vs deploy, Quick Deploy, troubleshooting failures, and when to graduate beyond Change Sets
๐ Enjoying This Free DevOps Course?
Share it with your Salesforce community — every share helps one more professional learn DevOps for free. 21,000+ learners this month!
All Free Resources → 75 DevOps Interview Q&As →Structure your answer as What → Why → How. Explain the concept before jumping to code!