+ Start a Discussion
m_roarkm_roark 

Unable to deactivate or delete classes and triggers in production SalesForce instance?

I was working on uploading some APEX code in our production environment, using the APEX Deployment Tool add-on for Apache Ant.  I downloaded the most recent version of this tool this morning, as I understand there were some issues with it over the last day or so.

Before I uploaded the code, I had wanted to delete a class created the other day, which had no triggers depending upon it.  However, I received the following error message when I attempted to do so.

BUILD FAILED
C:\Documents and Settings\RoarkM\Desktop\Apache Ant Files\build.xml:16: Failed:
Failed to delete class compileAndTest: Cannot complete this operation. Cannot delete classes/triggers in production.  Use compileAndTest verb to delete. : null

I have included the 'build.xml' file for this build below for anyone who would like to review it.

After realizing that I could not delete this class, I looked to find if there was a way of deactivating APEX triggers or classes in our production environment, as might be necessary if code were to become depreciated.  I could find no documented way through the UI or through the APEX Deployment Tools add-on to do this.

Are there plans to add this functionality, or an undocumented way to deactivate classes?  Has anyone else encountered issues deleting APEX code in production?  Did I misconfigure one of the elements below?

Any assistance would be greatly appreciated.


<project name="Sample usage of Salesforce Ant tasks" basedir="." xmlns:sf="antlib:com.salesforce">
  <property file="build.properties" />
  <property environment="env" />
- <!--
 Deploy to server 
  --> 
- <target name="deploy">
- <sf:compileAndTest username="${sf.username}" password="${sf.password}" server="${sf.serverurl}" apiversion="10.0" baseDir=".">
- <runTests>
  <class>compileAndTest</class>
  </runTests>
  </sf:compileAndTest>
  </target>
- <!--
 Cleans up above. (Deletes can be combined with compiles.) 
  -->
- <target name="delete">
- <sf:compileAndTest username="${sf.username}" password="${sf.password}" server="${sf.serverurl}" apiversion="10.0">
  <deleteClass>compileAndTest</deleteClass>
  <deleteTrigger>addTasksOnComplete</deleteTrigger>
  <deleteTrigger>reassignChildItems</deleteTrigger>
  </sf:compileAndTest>
  </target>
  </project>

gjsgjs
Unless you have a class called compileAndTest, you should not have deleteClass>compileAndTest</deleteClass>
m_roarkm_roark
I do have a class called 'compileAndTest'.  I followed the example of the class included in the APEX Deployment Tool, and stored all my test methods and static methods in this class.
gjsgjs
Whoops, should have read the whole script. We need to change the name of the sample class. There is a known bug for not being able to delete using compileAndTest. Working on a fix.
gjsgjs
Unless an issue is discovered during QA, fix will be released this week.
m_roarkm_roark
Thanks for the information.

Any ideas on how to deactivate classes or triggers without deleting them?  Is this functionality on the roadmap to be added to the APEX Deployment tools?
mtbclimbermtbclimber
For now you will need to comment out the functional statements that effectively "disable" your code and adjust your tests accordingly.   We're considering how best to support disabling triggers while still maintaining passing tests in your production environment.

Regards,
m_roarkm_roark
Thanks again for the information.  This is very valuable information, and you may want to consider adding it to the chapter in the APEX code language reference on deploying and managing APEX code.
jen.nelsonDEV@configero.comjen.nelsonDEV@configero.com

Any news on this?  I realize priorities change but the post indicating that this was being looked at (the ability to deactivate classes) was in 2007 (about 6 years ago).  Is there a new update?  Can anyone recommend other tools or options since we still can't do this through the UI; or is the only option still IDE?  Thank you!

Karen WheelerKaren Wheeler
Any updates on this? Years later??? I got the same error today - "Cannot Complete This Operation. Cannot Delete Classes/triggers In Production. Use CompileAndTest verb to Delete. :Null.