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
Rakshith RamachandraRakshith Ramachandra 

Not able to delete classes from Production.

I tried 3 different ways of deleting the classes from Production. First I tried using change sets and then the Eclipse force.com IDE. Now the ANT migration tool. Everytime I try to remove the class I'm getting this error. Please help!!

remove:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af3700000InZRSCA3
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy] Request Status: InProgress (12/14)  -- Running Test: TestTriggerCustomObjectUpdate.testBulkUpdate
[sf:deploy] -----------------------------------------------------------------------------------
[sf:deploy] Test Failures:
[sf:deploy] 1.  TestTriggerCustomObjectUpdate.TestReferralUpdate -- System.Exception: Assertion Failed: Expected: null, Actual: 00137000009XLFjAAO
[sf:deploy]     Stack trace: Class.TestTriggerCustomObjectUpdate.TestReferralUpdate: line 26, column 1
[sf:deploy] -----------------------------------------------------------------------------------
[sf:deploy] Request Status: Failed

BUILD FAILED
C:\Users\rramachandra\Desktop\salesforce_ant_35.0\ant-demo\build.xml:35:
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af3700000InZRSCA3

All Test Failures:
1.  TestTriggerCustomObjectUpdate.TestReferralUpdate -- System.Exception: Assertion Failed: Expected: null, Actual: 00137000009XLFjAAO
    Stack trace: Class.TestTriggerCustomObjectUpdate.TestReferralUpdate: line 26, column 1
2.  TestTriggerCustomObjectUpdate.testBulkUpdate -- System.Exception: Assertion Failed: Expected: null, Actual: 00137000009XLFkAAO
    Stack trace: Class.TestTriggerCustomObjectUpdate.testBulkUpdate: line 75, column 1

Code Coverage Failures:
1.  Class: chatter_answers_question_escalation_to_case_trigger -- Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
2.  Average test coverage across all Apex Classes and Triggers is 65%, at least 75% test coverage is required.
*********** DEPLOYMENT FAILED ***********

Is there a way to force delete? I'm new to salesforce and I have no idea about these terms "tests coverage" or even how/where to write a test on my own.
Best Answer chosen by Rakshith Ramachandra
tonantetonante
RakShith ,There are at least two ways you can do this:
A) 
  1. delete the class  by  creating an Eclipse  project based on Production classes or triggers etc.
  2. Go to that file's xml file and then set its status to  Deleted
  3. Save the xml file using Force.com -> Save To Server.
  4. Go to production and look at the classes, triggers etc, and verify that the classes are gone.
B) Another easy way to do it is:
look at: https://developer.salesforce.com/forums?state=id#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F00000008yIyIAI
 

All Answers

Rakshith RamachandraRakshith Ramachandra
I tried setting the file as InActive/Deleted. But it doesn't get saved. Gives me warnings (file saved locally but not on server). I tried doing Force.com -> save to server, but it doesn't work. Force.com-> Deploy to server gives me errors as mentioned above. I've been trying to delete these 2 classes for almost 2 days now. 
tonantetonante
RakShith ,There are at least two ways you can do this:
A) 
  1. delete the class  by  creating an Eclipse  project based on Production classes or triggers etc.
  2. Go to that file's xml file and then set its status to  Deleted
  3. Save the xml file using Force.com -> Save To Server.
  4. Go to production and look at the classes, triggers etc, and verify that the classes are gone.
B) Another easy way to do it is:
look at: https://developer.salesforce.com/forums?state=id#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F00000008yIyIAI
 
This was selected as the best answer
Rakshith RamachandraRakshith Ramachandra
User-added image

I've changed the status to Deleted. There's a warning which says "File only saved locally, not to server". I did Force.com->save to server twice but it didn't help. I can still see that class in production site. Active.

User-added image
 
Rakshith RamachandraRakshith Ramachandra
I'm just wondering if there's an order in which I need to delete these things maybe coz of dependencies. I'm pretty sure I'm doing all the steps right. Maybe it's not allowing me to delete the class because of some constraints.
tonantetonante
Didi you create a fresh Eclipse project downloading the Production classes or are you using Sandbox?
tonantetonante
Try that and if you get the same error then try and remove the dependencies.
Rakshith RamachandraRakshith Ramachandra

I created a new -> force.com project -> gave production username/pass/sectoken -> downloaded all the metadata. Changed the status in xml file. Tried to force.com -> save to server. It showed me the warning. 

How do I find/remove dependencies? Please let me know where to start.
tonantetonante
To find dependencies on your class go to Setup--> Develop-->Apex Classes Select the class you want to show dependencies on Click the button "Show Dependencies"
tonantetonante
On the class that references the class you want to remove, just remove//comment out the instruction in the code which references the class you are going to remove.
Rakshith RamachandraRakshith Ramachandra
Thank you tonante for all the help. I was able to remove all test failures with your help. However, I couldn't fix the "Code Coverage Failures". Please let me know if there's a quick way to fix them.

Code Coverage Failures:
1.  Class: chatter_answers_question_escalation_to_case_trigger -- Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
2.  Average test coverage across all Apex Classes and Triggers is 65%, at least 75% test coverage is required.
*********** DEPLOYMENT FAILED ***********


Thanks,
Rakshith
David Roberts 4David Roberts 4
I'm also struggling to remove a class.
I've tried all sorts. It says my code coverage is too low but the production estimate is good.
I tried creating a new project and using the production org but now it won't let me save or deploy to it.
Also, my code coverage list in force.com has some redundent classes. How can I refresh that list.
Why is this so complicated?