Sub topic 3
Deleting Added Components with Destructive Changes
Assume you understand Salesforce metadata, package.xml, Git, and basic Salesforce CLI deployments. A metadata rollback restores or deletes metadata. It does not automatically undo data changes or actions already taken by users and integrations.
Deleting Added Components
If a bad release added an Apex class, custom object, field, or other component, list it in a destructive changes manifest. The manifest uses the same metadata type and member name as package.xml.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>OrderHelper</members>
<name>ApexClass</name>
</types>
<version>60.0</version>
</Package>Deploy it as destructiveChangesPost.xml. “Post” means Salesforce deletes those components after deploying the regular package.
sf project deploy start \
--manifest manifest/package.xml \
--post-destructive-changes destructiveChangesPost.xml \
--target-org prod \
--test-level RunLocalTestsThe component must be deletable. References from flows, permissions, layouts, or Apex code can cause the deployment to fail. Check the deployment report before retrying.
Change Sets, Flows, and Active Configuration
Change sets do not provide a rollback button. Create a reverse change set containing the previous component versions and deploy it from the source org. For deleted components, use the appropriate destructive changes process instead.
Flows require extra care. Restoring an earlier flow version does not guarantee that the restored version becomes active. Include the intended flow version and activation state in your recovery steps. Also check active assignments, permission sets, custom settings, and other configuration that controls runtime behavior.
| Recovery target | Typical action |
|---|---|
| Added Apex class | Delete it with a destructive changes manifest |
| Previous flow behavior | Redeploy the prior version and activate it |
What Metadata Rollback Cannot Restore
A metadata redeploy cannot restore deleted or changed records, undo email or integration calls, reverse payments, or repair external systems. It also cannot reliably reconstruct configuration that was changed manually and never stored in source control. Record these items separately in the incident plan.
Rollback Runbook
A practical runbook should:
- Stop or cancel an in-progress deployment when possible.
- Identify the release commit and affected components.
- Retrieve or select the known-good metadata version.
- Redeploy it with required tests.
- Use destructive changes for newly added components.
- Restore flow activation and configuration states.
- Check data, integrations, and user-facing effects separately.
- Confirm the org state and document the incident.
Exercise
A successful release added OrderHelper and activated the wrong flow version. What should the rollback include?
Show answer
Redeploy the previous source, delete OrderHelper with a post-destructive changes manifest, restore the intended flow version and activation state, then check data and integration effects separately.