function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zoom_VZoom_V 

De-activate Apex Class in Production

Can I de-activate an Apex class directly in the production environment ? Right now I have some classes which are preventing me from deploying a change set because of some errors which I am getting them. The class is no longer being used in the production environment, so I would like to de-activate it - or do I need to do it through a change set ?

 

If I de-activate the classes in question will that be good enough for me to then have a successful change set deployment ?

 

Thank you for your help.

Best Answer chosen by Admin (Salesforce Developers) 
Saurabh DhobleSaurabh Dhoble

This is another weird thing about Salesforce - you cannot edit/delete/deactivate classes directly in production.

If you want to make any changes to a class deployed in PROD, you need redeploy it, with the changes.

 

For e.g., as Tech Force said, you can deploy your class via Eclipse, setting the status to InActive. You can also redeploy the class with all it's code commented out, which will get rid of the errors you are getting during deployment.

 

Usually, I would advise deleting the class - you can delete the class from your eclipse project, and then re-deploy, in which case it will allow you to delete it.

All Answers

Bhawani SharmaBhawani Sharma
You cannot delete a component from change set. So what you can do is, create a project in eclipse for production. Open meta.xml file of your class in eclipse and change the status to InActive.
Saurabh DhobleSaurabh Dhoble

This is another weird thing about Salesforce - you cannot edit/delete/deactivate classes directly in production.

If you want to make any changes to a class deployed in PROD, you need redeploy it, with the changes.

 

For e.g., as Tech Force said, you can deploy your class via Eclipse, setting the status to InActive. You can also redeploy the class with all it's code commented out, which will get rid of the errors you are getting during deployment.

 

Usually, I would advise deleting the class - you can delete the class from your eclipse project, and then re-deploy, in which case it will allow you to delete it.

This was selected as the best answer
Zoom_VZoom_V

Thank you very much for your responses you guys. I ended up going into Eclipse and changing the XML setting to "Deleted". That did the trick. 

 

Salesforce needs to get that feature for classes.

 

Thanks again.