How to Deploy Changes Between Salesforce Sandboxes - Solution for Guru

Table of Contents
< All Topics
Print

How to Deploy Changes Between Salesforce Sandboxes

📝 Summary

This article outlines the step-by-step process for deploying changes between Salesforce sandboxes (e.g., from a Developer Sandbox to a QA or UAT Sandbox). Deployment helps ensure that configurations, code, and metadata are properly tested and transitioned through your release pipeline.


📌 Prerequisites

Before you begin, ensure the following:

  • You have appropriate permissions in both source and target sandboxes.
  • You have a basic understanding of Salesforce metadata types.
  • Your sandboxes are active and accessible.
  • Change sets or Salesforce DevOps tools (e.g., Salesforce CLI, Gearset, Copado) are available.

🚀 Deployment Methods

Option 1: Using Change Sets

  1. Login to the Source Sandbox
    • Navigate to Setup.
    • In Quick Find, type Outbound Change Sets and click it.
  2. Create an Outbound Change Set
    • Click New.
    • Name your change set and provide a description.
    • Click Save.
  3. Add Components
    • Click Add to include components (e.g., Apex Classes, Objects, Page Layouts).
    • Use filters to find and add the necessary metadata.
    • Click Add to Change Set.
  4. Upload Change Set to Target Sandbox
    • Click Upload.
    • Choose the target sandbox (must be connected in a deployment connection).
    • Click Upload.
  5. Login to the Target Sandbox
    • Go to Inbound Change Sets in Setup.
    • Find your uploaded change set.
    • Validate, then Deploy the change set.

Option 2: Using Salesforce CLI (SFDX)

  1. Authorize Sandboxes

sfdx auth:web:login -a DevSandbox
sfdx auth:web:login -a QASandbox

2. Retrieve Metadata from Source

sfdx force:source:retrieve -u DevSandbox -m “ApexClass:MyClass”

3. Deploy Metadata to Target

sfdx force:source:deploy -u QASandbox -p force-app

4. Check Deployment Status

sfdx force:source:deploy:report

✅ Best Practices

Use naming conventions for change sets.

Perform validation before deployment.

Always run all tests in the target org.

Document changes and maintain a deployment checklist.

Use version control (e.g., Git) if you’re using SFDX or DevOps tools.

🛠 Troubleshooting

IssueSolution
Missing componentsMake sure all dependencies are added to the change set.
Deployment failedCheck error messages and ensure all tests pass.
Components not availableVerify metadata type support in the sandbox and API version.