+ Start a Discussion
RelaxItsJustCodeRelaxItsJustCode 

How do you deactivate a class that has been pushed to Production?

How do you deactivate a class that has been pushed to Production?

 

Don't get me wrong I've got some really good unit test results but before I release, I just have gotta ask, if things do go wrong how do I pull back and deactivate a class, a service class, and trigger that have been pushed to production from the force IDE?

 

Thank you,

Steve Laycock

SFFSFF

Two different answers, depending:

 

For classes, you can delete a class from production from the Eclipse IDE. You just create a project for production, refresh it, and delete that class from production. Of course, depending on what references this class, you may or may not be able to delete it; you may have break these references first.

 

For triggers, you can just delete them OR you can inactivate them. From Eclipse, you inactivate a trigger from the metadata tab on the trigger - set the <status> to "Inactive".

 

Commenting out the contents of the code also works, depending on whether you want the change to be permanent or not.

 

Hope this helps,

crop1645crop1645

You should also be able to redeploy the older versions of the class/trigger from Eclipse (these are kept in the project/deployment directories as part of the Eclipse deployment sequence. Be conscious of logical consistency of your redeployment set as noted above 

 

For something that you might want to conditionally disable is to code the class to execute only if a custom setting 'parm' is set to true. Then you can disable your new functionality by merely updating the custom setting

 

example custom seting: Parm__c

example fields:

  parm_name__c String

  parm_value__c Boolean

 

a row might be:

parm_name__c = 'disableClassA'

parm_value__c = true

 

Your apex Class A code reads the custom setting (doesn't consume a SOQL call) and decides what to do (execute or not some method, block of methods)