How to Use Change Sets Effectively in Salesforce
📝 Summary
This article explains how to use Change Sets in Salesforce for deploying metadata components between connected orgs (typically from a sandbox to production). It also highlights tips, limitations, and best practices to ensure efficient and error-free deployments.
⚙️ What Is a Change Set?
A Change Set is a packaged bundle of metadata components (like Apex classes, objects, workflows, and layouts) used to move changes from one Salesforce org to another.
🔁 Deployment Flow Using Change Sets
- Develop and Test in a sandbox.
- Create an Outbound Change Set in the source org (e.g., Dev or QA sandbox).
- Upload the Change Set to the target org (e.g., UAT or Production).
- Deploy the Change Set from the target org using Inbound Change Sets.
🛠 Step-by-Step Guide
✅ Step 1: Create a Deployment Connection
- Automatically created between Production and its sandboxes.
- Verify in:
Setup > Deployment Settings
✅ Step 2: Create an Outbound Change Set
- Go to
Setup > Outbound Change Sets
. - Click New.
- Provide a name and description.
- Click Save.
✅ Step 3: Add Components
- In the Change Set, click Add under the “Change Set Components” section.
- Select the component type (e.g., Apex Class, Custom Object).
- Select one or more components.
- Click Add to Change Set.
📌 Tip: Use filters to quickly locate metadata.
✅ Step 4: Add Dependent Components
- Click View/Add Dependencies.
- Review and add any required dependent components (e.g., fields, permission sets).
✅ Step 5: Upload the Change Set
- Click Upload.
- Select the target org (must be connected).
- Confirm and upload.
✅ Step 6: Deploy from the Target Org
- Log in to the target org.
- Go to
Setup > Inbound Change Sets
. - Locate and click on the received Change Set.
- Click Validate to simulate deployment.
- Click Deploy to apply the changes.
🎯 Best Practices for Using Change Sets
Best Practice | Description |
---|---|
Use meaningful names | Include ticket number, environment, and purpose in the Change Set name. |
Add dependencies | Use the “View/Add Dependencies” button to avoid missing required components. |
Validate before deploying | Prevents issues during actual deployment. |
Include test classes | Ensure you deploy associated test classes for new or updated code. |
Run all tests in production | Required for Apex deployments; ensures system integrity. |
Document the Change Set | Use the description field to log changes or links to change tickets. |
Clone when needed | Reuse and modify existing change sets for similar deployments. |
⚠️ Limitations of Change Sets
Limitation | Detail |
---|---|
Only works between connected orgs | Can’t deploy between unrelated orgs or scratch orgs. |
Not all metadata types are supported | For example: Email Templates, Reports, Dashboards. |
Manual process | No automation or version control integration. |
No rollback | You cannot undo a Change Set deployment automatically. |
Cannot schedule deployments | Requires manual action from the target org. |
🧪 Troubleshooting Tips
Issue | Solution |
---|---|
Missing components | Use “View/Add Dependencies” or manually add missing metadata. |
Deployment errors | Review error log, fix issues, re-upload. |
Test failures | Make sure all test classes and dependencies are included. |
Components not updated | Double-check you’re uploading the latest version. |
🏁 Summary
Change Sets are a simple and native way to deploy customizations between Salesforce orgs. By following best practices, understanding limitations, and validating changes, you can ensure smooth and successful deployments.