+ Start a Discussion
sales4cesales4ce 

How to delete/inactivate classes in Production Instance

Hi,

 

We have some apex classes that have been deployed 3 years back without test classes.

Our production organization Now has exactly 75% code coverage( when i ran ALL APEX TEST Classes).

 

I have created a new trigger which needs to be deployed to the production. When trying to deploy the trigger and Its test class via Force.com IDE, it raises a error saying overall code coverage is 73%.

 

Now i want to deactivate/delete those apex classes that do not have test classes written.I do not know that why they have written and they are no longer used.

How can i accomplish this task of deactivating/deleting..

I tried searching the posts, but could not get a definitive way to accomplish this.

 

Any help or idea on this is highly appreciated.

 

Thanks,

Sales4ce

 

Best Answer chosen by Admin (Salesforce Developers) 
paul-lmipaul-lmi

There's no way to "deactive" a class.  It's either live, or non-existent.  By delete, I mean, literally delete the class, and then deploy the container/folder above it (those, tell the target org that it doesn't exist, and give the option to remove it as part of the deployment).

  1. In dev org, right click desired class to delete
  2. Select delete.  Click yes or OK
  3. Right click the Classes folder, then select Force.com > Deploy
  4. Log in with Prod org credentials
  5. In the deployment window, deselect everything but the Class you want to remove from Prod
  6. Continue the wizard.
  7. Class removed from Prod.

Active/Inactive, to my knowledge, is not something you can manually set, but rather, something the platform does for some reasons, such as a class becoming invalid due to dependencies on another class failing, etc.

All Answers

paul-lmipaul-lmi

you have to delete them from the "source"/dev org they were created in, and then deploy that change to the target/prod org.  You use Eclipse > right click Classes folder > force.com > deploy to server.  Then, find the ones you want to delete, in red.

sales4cesales4ce

Thanks for your reply! 

I believe and understand that Deleting them from Dev org is changing the associated XML file of the class to "Inactive/Deleted".

 

I am confused at this step:

After changing the XML file of the associated class, I then save this back to the server.

But this did not change the class to "Inactive" back in my dev org. Can you let  me know why this isn't saving back the class to inactive?

 

I would certainly appreciate if you can provide an example with steps.

 

Thanks for your help on this.

 

Sales4ce

paul-lmipaul-lmi

There's no way to "deactive" a class.  It's either live, or non-existent.  By delete, I mean, literally delete the class, and then deploy the container/folder above it (those, tell the target org that it doesn't exist, and give the option to remove it as part of the deployment).

  1. In dev org, right click desired class to delete
  2. Select delete.  Click yes or OK
  3. Right click the Classes folder, then select Force.com > Deploy
  4. Log in with Prod org credentials
  5. In the deployment window, deselect everything but the Class you want to remove from Prod
  6. Continue the wizard.
  7. Class removed from Prod.

Active/Inactive, to my knowledge, is not something you can manually set, but rather, something the platform does for some reasons, such as a class becoming invalid due to dependencies on another class failing, etc.

This was selected as the best answer
b-Forceb-Force

If you have full sandbox environment ,

refresh it

do your changes and deploy to production .... I know this is not that straight forward ....but this is the only way

 

 

Thanks,

Bala

sales4cesales4ce

Thanks Paul! That certainly helped me understand better.

tonante27tonante27

You can Inactivate triggers from development to Production using the XML edit but I have yet to do this with classes in Force IDE.  It would be quick and cleaner if you could.