+ Start a Discussion
Kou XiongKou Xiong 

How to removed non-coverage code from production?

I have some triggers and classes that we no longer use that was pushed to production by the previous admin.  These codes have no coverage or don't meet the coverage requirement.

How would I remove these?  I've already tried Eclipse and Workbench but all came back with errors because of failed tests.
Jessica RiffeJessica Riffe
In order to delete code classes from production, you will need to use the Force.com migraiton tool and create a destructiveChanges.xml file.

Information here (https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/daas_destructive_changes.htm)

You could also use this in combination with the Salesforce CLI.  This takes quite a bit of reserach, especially if you haven't used it before as there is setup and a learning curve.

If you need to remove the code from the code base until those classes can be removed, then you can simply comment out the unused code.  Which I would recommend doing first anyways before truly deleting the classes.
Jessica RiffeJessica Riffe
Also, if your tests are failing, then there are references to the code that is being deleted.  Which would cause those classes to no longer compile and fail miserably.  Those would also have to be modified or commented out/removed.
Deepali KulshresthaDeepali Kulshrestha
Hi Kou,

There is no need to use any other software for deleting your trigger and apex classes from production.

If you know the names of those classes, then you can simply search the apex trigger from Setup and delete those triggers from there.

Also, search Apex classes in the setup and delete those classes.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Kou XiongKou Xiong

I tried the destructiveChanges method but because our org is under the 75% code coverage, it won't allow any deletes or changesets to be pushed.


Can't delete from production because of code coverage being under 75%.  Deleting from sandbox doesn't delete from production?