How to Delete or Deactivate Apex Class / Trigger in Salesforce Production Org

How do you delete or deactivate the apex classes / triggers on your Salesforce Production Org? Unfortunately, it is not as simple as going to the Apex class and hitting the delete button or unchecking the ‘Active’ checkbox.

For deleting or disabling the code, you can take one of the following two routes:

1. Probably the simplest way to delete / disable is to connect to your Salesforce production org from VS Code download the apex class / trigger, change the status of the Apex class / trigger to “Deleted” or “Inactive” in the class/trigger XML file and save. In this step-by-step guide we are going to cover this method.

2. The 2nd way is to use ANT Migration tool and here is the link to a knowledge article on how to use this method.

(If you are not familiar with ANT Migration tool here is just the guide you need – Step-by-Step Guide on Getting Started with Salesforce ANT Migration Tool)

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

13 thoughts on “How to Delete or Deactivate Apex Class / Trigger in Salesforce Production Org”

  1. Everything worked until we tried to ‘Deploy Source to Org’. The Problems log is empty. Can’t attach screenshot

    1. Hi Milad, it will be a bit difficult to troubleshoot without knowing any further details. One thing that you may want to check is whether your user has the “Author Apex” permission in the org. The other option will be to log a case with Salesforce support and get their help.

  2. Everything here worked until ‘deploy source to org’ which fails for both classes and triggers. What could be wrong?

  3. Maybe this is a little bit late, but the easiest way is to use Custom Labels with a True/False value that you reference in your trigger logic

  4. I followed the slide show exactly, changed the xml for the the metadata fro active to deleted, and checked in Salesforce and the Apex classes were still active. Do you have a further solution or idea as to why this is not working?

  5. Thank you! Step 1 worked perfectly for me. The slideshare was also very helpful as I was not very comfortable in Eclipse. Thank you again! Dan

  6. Hi Sam, once you save the changes, can you log on to to your Salesforce org in the browser and check the status of the trigger/apex class there. The changes should be reflected there.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Introducing All Access Pass