Delete and deploy components from production using workbench

| By Webner

How to delete and deploy components (Apex classes, Flows, Objects, etc) from production using workbench?

We cannot delete Apex classes directly from the Production org. Also, it is not possible to deploy deleted apex classes using Changeset. So, to delete them we can use these tools – Workbench, IDE, Ant Migration, etc.

In this post, we will get to know how we can add/delete/update various components at a single go from Production using Workbench. This is the easiest and fastest way that does not require any additional software.

We need two XML files to perform operations(add/update/delete) on components.

  1. package.xml: It is a project manifest file that contains all the components to retrieve or deploy only.
  2. destructiveChanges.xml: For deletion, we need to create a delete manifest destructiveChanges.xml file.

Both files have the same format.

Step 1. Create destructiveChanges.xml file.
Below you can see the package.xml and destructiveChanges.xml files:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="">

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="">
// To delete specific Apex Classes
<members>ApexClassName 1</members>
<members>ApexClassName 2</members>
// To delete specific Apex Triggers
<members>ApexTrigger Name 1</members>
<members>ApexTrigger Name 2</members>
// To delete specific Custom Objects

Step 2. Now both the files should be archived in a .zip file and ready to deploy your changes to Production Org.

Step 3. Login to your Production Org from Workbench ( Here is the Screenshot:
workbench 1

Step 4. Open Deploy page from Migration drop down and browse zip file (containing package.xml and destructiveChanges.xml) to deploy. Here is the screenshot:
workbench 2

Step 5. Click Next to deploy changes.

To add and delete components in single deployment:

You can perform the addition and deletion of components at the same time. It will delete components in destructiveChanges.xml and add/update components in package.xml.
By default, deletions are processed before component additions. The capability to define when deletions are processed is helpful when you’re removing components with dependencies. The process/steps will be the same, the difference is in the name of destructiveChanges.xml file.

  • If we want to delete components before adding/updating other components, we have to create a manifest file with name- destructiveChangesPre.xml and include the components in it to delete.
  • If we want to delete components after adding/updating other components, we have to create a manifest file with the name destructiveChangesPost.xml and include the components in it to delete.

Leave a Reply

Your email address will not be published. Required fields are marked *