With FlexDeploy’s 22.214.171.124 release, you can now delete components from Salesforce Orgs, along with retrieving and deploying to Salesforce Orgs. This feature — Support of Destructive Packages — helps you keep your Org cleaned by removing retired or not required components.
With FlexDeploy, achieving this is very simple and as easy as checking a checkbox for one or more files in your package. In this blog, I will give details on how to achieve this. If you have not already set up your Salesforce instance in FlexDeploy, start with the setup as described here.
Define the Package
The process of defining or creating the package is the same for destructive changes as it is for regular deployments. You can simply create a new package and add files. Or, if you have an existing package and would like to select files for deletion, just open the Package by clicking on it.
Both Org to Org package deployment and SCM to Org package deployments are supported.
Marking the File as Destructive
Once you are in the Package screen, you can add additional files that aren’t already in your package. If you have the files, you can directly mark them as destructive.
Next, to mark the files for deletion, we need to make the files as a Destructive change. This is the key step for this action. You need to click on the Kebab menu () at the end of the file row. And then select “Set Destructive.”
If you need to mark more files, you can repeat the process or filter the files using the magnifying glass. Then, select the down arrow menu next to the file count and either mark files as destructive or remove the destructive flag.
Please make sure that you really want to delete the files from you Salesforce Org before making these destructive.
Deploy the Destructive Package
Deploying a destructive package is exactly the same as any other package deployment. You can create a version by using the Build button and then submit the Deployment to any Salesforce Org. You can take advantage of CI/CD pipelines by adding the package to a release to automate the promotion of the destructive package along the environment.
In FlexDeploy, these destructive packages are tracked and the state of the files is handled automatically. FlexDeploy tracks who deleted what, when, who approved, etc. for compliance and audit requirements. You don’t need to do anything to achieve this visibility.
It is simple to delete the files you don’t need in your Salesforce Org. With FlexDeploy you can migrate some metadata files and delete others, all in the same release. You can safely delete one or many with Validate before deleting. If you need files back for some reason, you can uncheck the flag and simply deploy to re-create the files. You can achieve high-quality DevOps with your Salesforce application with built-in internal or external approvals, notifications, and Test Automation integration.