Is there a way to delete apex classes from production?

Is there a way to delete apex classes from production?

When attempting to delete Apex Classes & Triggers from Production, you can be faced with a number of issues. This is due to the fact you cannot modify Apex code directly in production. Within this article, I will go through a lightweight, and flexible solution, that enables you to delete Apex classes and triggers from production.

How to delete apex classes and triggers in Salesforce?

The most common approach to deleting Apex classes and triggers in a Salesforce production environment is to leverage either the Force.com IDE or the Force.com Migration tool. These tools have a number of downsides, namely: -The Force.com IDE is very ‘heavyweight’ and is known for being quite buggy sometimes and unpleasant to use.

How to turn off the apex trigger in production?

Then in your apex trigger, add an IF condition at the top to check if the Trigger status in Custom settings is TRUE, only then run the entire apex trigger code. Every time you would like to turn off the trigger in production, You just need to go to your custom settings and uncheck the IsActive checkbox for that trigger.

Can you delete a class from a sandbox in production?

You cannot delete a class in production directly. You will need delete the class from your sandbox and then deploy the deletions to your production org. When you deploy from sandbox to production, the missing classes will come up in red and you can choose to deploy these deletions to Production.

How can I delete two classes at the same time?

Replace SomeClass with the name of your class that you wish to delete. If you have two classes that need to be deleted at the same time, you can simply add another row into the file with the name of the other class, for example: 4. Save this file name as destructiveChanges.xml (note the capital ‘C’ in ‘changes’).

How do I create a class in apex?

Creating a class and deploying it from a sandbox environment to the production environment has been simple: Under “Custom code > Apex classes”, create a class and test. Create a change set in sandbox. Deploy the change set in production.

How to delete classes and triggers from Salesforce.com?

The Ant Migration Tool was a very popular option for deploying code before the SFDX CLI was introduced, but it’s still supported. To delete code using either tool, we create a special file called destructiveChanges.xml which works exactly like a package.xml file.

How do I delete a class in destructivechanges.xml?

Replace SomeClass with the name of your class that you wish to delete. If you have two classes that need to be deleted at the same time, you can simply add another row into the file with the name of the other class, for example: Save this file name as destructiveChanges.xml (note the capital ‘C’ in ‘changes’).