How to Disable or Delete an Apex Trigger or Class from Production Organization ?

Apex code can’t be modified directly within a Production organization, so it requires steps using Developer tools, like the Force.com IDE.

Steps to Remove or Disable Apex Classes/Triggers

1. Force.com IDE should be installed.
2. Connect to the Production Instance using the IDE and find the class or trigger that you want to delete.
3. Open the matching .xml file, and change the Status XML tag from Active to Deleted.

 <?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
 <apiVersion>31.0</apiVersion>
 <status>Deleted</status>
</ApexClass>

4. Or to disable the trigger change it to Inactive.
Note: Apex class Status can only be changed to “Active” or “Deleted,” not “Inactive”.
5. Save the file.
6. Select the two files (Code and XML) using “Ctrl-click,” and then right-click on one of them.
7. Select Force.com | Save to server. (To delete in connected org.)

To delete in another org

8.Select Force.com | Deploy to server.
9. Provide your credentials for the destination org and follow the steps.
Author:

Ajomon Joseph AJOMON JOSEPH
Senior Salesforce Architect
In Connect me on LinkedIn
twitter Follow me on Twitter @apexcoder
blogger Subscribe to my blog https://apexcoder.com
email Email me ajomon@apexcoder.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s