Rollback Changes in Salesforce Using FlexDeploy
In Salesforce development, rollback capabilities are essential for managing and mitigating issues that arise from deployments. Rollback allows you to revert changes and restore the system to a previous, stable state. FlexDeploy, a comprehensive DevOps tool, offers several methods to facilitate rollback, including Versioned Artifacts, File Revisions, and Backups Repository. This documentation provides an overview of these rollback methods and guides you through their implementation in FlexDeploy.
Understanding Rollback
What is Rollback?
Rollback is the process of reverting a system to a previous state. In Salesforce, this often means undoing changes to metadata such as Lightning Web Components, Lightning Flows, Apex Classes, and Layouts. Rollbacks are essential for correcting errors, addressing unforeseen issues, or reverting to a stable version of an application after a failed deployment.
Why is Rollback Necessary?
Error Correction: During deployment, changes can introduce errors or conflicts. Rollback allows you to undo these changes and restore system functionality.
System Stability: Rolling back helps maintain system stability by reverting to a previously tested and stable state.
User Satisfaction: If a deployment causes issues for users, rolling back can quickly restore the previous, functional version, minimizing disruptions.
FlexDeploy and Rollback
FlexDeploy offers several options to rollback, each providing flexibility depending on the rollback needs. After each Deploy execution, FlexDeploy provides an option to initiate a rollback, allowing users to revert changes made during the deployment.
1. Project Version (Versioned Artifacts)
FlexDeploy maintains a history of builds and deployments through versioned artifacts. Each build creates a new version of the package, allowing you to deploy any previous version of a package if you need to rollback to a prior state.
When to Use This Option: When you need to revert to a previous state for all files or specific files within a package, you can use Project Version Source Type for rollback. This option is ideal if you want to restore the package or individual files to a prior state quickly and efficiently.
a. Navigate to the Package Execution and identify the previous version.
b. Click on the Rollback button in the latest deploy execution row - Select Project Version Source Type and previous version as Rollback Value.
c. Click Submit to initiate the rollback process.
2. SCM Revision
When files are committed to a source control system (such as GitHub, GitLab, or Azure), a commit history and file revisions are created. FlexDeploy can leverage these revisions for rollback.
When to Use This Option: When you need to revert to a prior state for one or specific files within a package, you can use SCM file revisions for those files. This option is ideal if you only need to restore individual files or a subset of files to a previous version in a package.
a. Click on the Rollback - Select SCM Revision Source Type and choose the correct File Revision as Rollback Value.
b. Click Submit to initiate the rollback process.
3. Backups Repository
FlexDeploy takes backup of the metadata from the target org before deployment and stores these backups in a designated Backups Repository on the FlexDeploy server. FlexDeploy's Backup Repository needs to be configured in order to use this option.
When to Use This Option: When you need to revert to the previous state of files that were affected by the current deployment, you can use the Backups Repository for rollback. This option is particularly useful if you want to restore files to their pre-deployment state. Before deployment, FlexDeploy saves a backup of the affected files, allowing you to deploy these backups if a rollback is necessary. This option ensures that you can restore files to their original state before the recent changes were applied.
a. To view or download a backup, navigate to the deployment where the backup was created. Click on Artifacts, and the Backups will be displayed below the Artifacts.
b. To restore the backed-up files, Click on the Rollback - Select Backup Repository Source Type and current version as Rollback Value.
c. Click Submit to initiate the rollback process.
d. Alternatively, you can add the backed-up files to source control and manually build and deploy them.
4. Delete (Rollback Option for Deleting Files)
The rollback process also allows you to remove/delete files that were newly deployed or mistakenly deployed to the target org. This option is useful when you need to undo changes by deleting specific files or components from the target org.
If you want to delete files from the target Salesforce Org as a part of a rollback, follow these steps:
a. Click on Rollback - Select the Delete option. Use the toggle button to select the specific files that you want to delete.
b. Click Submit to initiate the rollback process.
Rollback for Data Files (Data Deployment)
FlexDeploy also supports rollback for Data Files (e.g., .csv files) containing Salesforce object records. After a data deployment, FlexDeploy allows users to revert records or data changes if necessary.
Currently, FlexDeploy only supports rollback for data files using Project Version with the following limitations:
When to Use: If data (such as Salesforce Object records) have been inserted or modified (updated or upserted), and you need to revert the data back to a previous state, you can use the rollback option to restore the earlier version of the data.
Example Scenario:
When you initially insert data, FlexDeploy will deploy that data in the target org.
If you later perform updates or upserts on those same records (for example, modifying the records), and then you want to revert to the original state, you can use the rollback option.
The rollback will restore the data to its prior state, undoing the updates or changes made to the records since the last insert.
a. Click on the Rollback - Select Project Version Source Type and previous version as Rollback Value.
b. Click Submit to initiate the rollback process.
Additional Notes for Rollback
1. Skip: If you want to perform a rollback for specific files (and not all files in the deployment package), FlexDeploy allows you to Skip any files that do not need to be rolled back, even if they are listed in the package. This ensures that only the files you select will be reverted, while others will remain unchanged.
2. Notes: Before submitting a rollback request, you must provide Notes. This field is mandatory for all rollback requests, and it is available for all workflow request types. The note can be reviewed later in the project execution history or in reports.
Rollback capabilities in FlexDeploy for Salesforce development offer flexibility, precision, and confidence in deployment management. Whether you are reverting a full deployment or rolling back specific components, FlexDeploy’s versioned artifacts, file revisions, and backups repository provide the tools necessary to ensure system stability and minimize downtime. By integrating rollback strategies into your deployment workflow, you can ensure smoother, more reliable Salesforce development and maintenance.
For more general details on FlexDeploy’s rollback capabilities, see Rolling Back a Deployment.
- style