How to delete Apex Class or Trigger


1. Have a package.xml file with listed items to delete


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

   <types>

       <members>triggerTasks</members>

       <name>ApexTrigger</name>

   </types>

   <version>63.0</version>

</Package>


2. Retrieve items using Workbench

 2.1. Go to https://workbench.developerforce.com/login.php and login

 2.2. Go to Migration -> Retrieve

 2.3. Use the package.xml file 

 2.4. Click Next

 2.5. Click Retrieve

 2.6. Once the retrieval is done there will be a "Download ZIP File" link. Download the file and send it to me.


3. Unzip the archive


4. Change trigger-meta.xml (for Apex trigger) or cls-meta.xml (for Apex class).

Status tag should have “Deleted” value in it. <status>Deleted</status>


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

<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">

    <apiVersion>50.0</apiVersion>

    <status>Deleted</status>

</ApexTrigger>


5. Archive the class/trigger folders and package.xml file



so the content of the resulting archive is just a package.xml file and classes/triggers folders.


6. Deploy the archive with Workbench


 6.1. Go to https://workbench.developerforce.com/login.php and login

 6.2. Once logged in go to Migration -> Deploy

 6.3. Select the file archive file

 6.4. Check "Single Package" flag

 6.5. Click Next

 6.6. Click Deploy