+ Start a Discussion
Ian Kang 1Ian Kang 1 

how can I remove a trigger and test class from production?

So there is an APEX Trigger and APEX Test Class I deployed in production. 

It turned out the APEX Trigger is not working well, so I tried to removed the Trigger; however apparently there is no way I can delete a trigger from production.  Instead, I need to deactivate the trigger and push that to production.  

And here comes the problems.
- How can I meet 75% code coverage when the trigger is inactive?  it won't run, right?
- Even if I somehow manage to deactivate the trigger in Production how can I delete the test class from production which is no longer valid (since its trigger is now inacive).  It will always fail the local test

Best Answer chosen by Ian Kang 1
Ramesh DepaiahRamesh Depaiah
@Ian 
      Once you deploy it as deactivated it no longer needs 75% coverage
  • Disable the trigger in a Sandbox environment [You should have a Sandbox org which contains the same trigger]
  • Create a new Outbound Change Set in the Sandbox
  • Add the disabled trigger to the Change Set
  • Upload the Change Set to your Production Org
  • In Production, go to Inbound Change Sets and wait for the uploaded Change Set to be available
  • Click Deploy to run the tests and apply the changes
Delete Testclass:
1) From Force.com IDE, select the class that you want to delete (Look for .xml extension )
2) Open that .xml version of your class and change the Status tag to Deleted.
3) Right click and save the file.
4) Now select "SRC" folder and right click--->Select  Force.com---> select Deploy to server
5) Log into your production org and follow the steps.


Thanks
Ramesh

All Answers

Ramesh DepaiahRamesh Depaiah
@Ian 
      Once you deploy it as deactivated it no longer needs 75% coverage
  • Disable the trigger in a Sandbox environment [You should have a Sandbox org which contains the same trigger]
  • Create a new Outbound Change Set in the Sandbox
  • Add the disabled trigger to the Change Set
  • Upload the Change Set to your Production Org
  • In Production, go to Inbound Change Sets and wait for the uploaded Change Set to be available
  • Click Deploy to run the tests and apply the changes
Delete Testclass:
1) From Force.com IDE, select the class that you want to delete (Look for .xml extension )
2) Open that .xml version of your class and change the Status tag to Deleted.
3) Right click and save the file.
4) Now select "SRC" folder and right click--->Select  Force.com---> select Deploy to server
5) Log into your production org and follow the steps.


Thanks
Ramesh
This was selected as the best answer
Ian Kang 1Ian Kang 1
@Ramesh
thanks for your help. 

but how can I deploy a deleted test class from sandbox to production?
I have followed the steps in a sandbox and I cannot include the deleted test class in a change set - because they are deleted 

It seems not working
Ramesh DepaiahRamesh Depaiah
@Ian
You must use eclipse or workbench
follow this steps http://carvingintheclouds.blogspot.com/2013/12/deploying-destructive-changes-using.html

Thanks
Ramesh