As Bob suggested, you should first delete it from your sand box using force.com IDE.
Below are the steps:
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.
Note: if you have any test class for the class that you are deleting make sure you do the same like above and then select those 2 classes for final deployment.
You need to delete it from your classes directory on your sandbox and then deploy your classes directory to production. In the deployment window you should then see the option to delete the classes from the target organization.
As Bob suggested, you should first delete it from your sand box using force.com IDE.
Below are the steps:
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.
Note: if you have any test class for the class that you are deleting make sure you do the same like above and then select those 2 classes for final deployment.
I usually delete the class from my sandbox and then deploy the whole of the classes directory. This picks up the fact that my sandbox has deleted classes compared to production and the classes appear as delete options.
Of course I usually then uncheck every other class, but that's optional depending on if your sandbox is different to production.
Why doesn't this work for me? I open the metadata on an inactive trigger. I change the status from Inactive to Deleted. I right click on the metadata file, hover over Force.com menue, and select save to server. When its done I check the sandbox org and its still there. Then when I click on the open metadata file in Eclipe a message pops up saying, "The File 'Dev Apex/src/triggers/npsToJBara.trigger-meta.xml' has been changed on the file system. Do you want to replace the editor contents with these changes?" If I click yes it changes the status back to Inactive in Eclipse, If I click No it just asks me that again the next time i click on the open metadata... what the crap?
I have selected multiple classes and their test classes and deploy them though IDE the result is that all test classes deleted but main classes are still there in production. Can any body let me know how i can delete those classes? Starz26 can you please help me?
I think the information on this thread is a bit stale. As far as I can tell, connecting directly to production and changing the status to "Deleted" no longer works reliably and runs the risk of causing test coverage issues on your production environment. Neither can you simply change the XML status to Deleted on your sandbox as instructed here (https://help.salesforce.com/apex/HTViewSolution?id=000006188&language=en_US). The only reliable method I found is to log into your sandbox (refresh it from production first if it's gotten out of sync), delete the classes from Setup->Develop->Classes, which will probably force you to first delete dependencies (i.e buttons, pages, etc). Then go into the Force.com IDE, refresh from the sandbox server, delete the classes from your local workspace, and then deploy the entire "src" directory to production. Now you will be shown the pages and classes to delete when it gathers the deployment payload.
I first tried the shortcut method of connecting directly to production and setting the XML status to Deleted, and it worked on my test classes but refused to delete anything else. Of course this caused every deployment thereafter to fail because I no longer had sufficient test coverage on production. I had to gather all that code from an old sandbox, redeploy it to production, and then go through the proper steps outlined above. And it worked flawlessly.
TL/DR: Don't bother with the shortcut, it will cause more problems than it solves.
In the the Eclipse Force.com IDE I right clicked on the class and chose delete. If you preview you get the option to delete from server as well. Worked for me.
@Amul : There are different ways to delete the class form sfdc instance. The simplest way which worked for me is deleting from Eclipse IDE. 1. Just Right Click the class in IDE which you want to delete. 2. It will ask for a confirmation "Are you sure you want to delete file "classname" ?" Click "Yes". 3. Next confirmation will ask you "The requested operation will only delete the resource locally. Would you also like the resource to be deleted from the server?" 4. Click yes and the class is deleted from SFDC instance.
I tried that and it only deleted from the Sandbox org but not production. If you wish to delete from production you'll have to update the XML meta fiule setting the Status element to "Inactive" and saving that file. Then this should remove from production.
I've tried updating the metadata and then deploying to another sandbox so I can test this before I actually do this in Production. When I go to deploy, it prompts me to overwrite the class but also shows no changes. When I check on the server I've deployed to, the class is still there and Active.
I came across your steps, after changing the status from Active to Deleted, I don't have option to Save to server/Deploy to Server for the particular Apex class which is under the installed package. Any help here it would be great.
I found that you have to make sure that depedencies associated with the Class have to be deleted from Production before you deploy from the IDE. I kept getting failures from the IDE, once I deleted a Tab and VF page that was accessing the Class, I was able to deply and remove using the above steps. An easy way to find the dependencies is, once the Sandbox has been setup, just try to delete the Class from there using the Delete button, SF will tell you the dependencies. Just delete those and the IDE method will alow you to deploiy successfully to Production once you have deleted the depencies there as well.
I thought I wasn't deleting the class. It seems there is a delay in the update to the production org. I left the office feeling very frustrated that, whatever I had tried, the class stubbornly remained. The next morning I found it had gone! Hope this helps someone avoid the frustration that I felt.
@Starz26 That worked perfectly for me. I deleted the classes and associated tests at the same time, and haven't had any issues. I suspect that not deleting them at the same time may cause problems.
Deleting from SB and then loading all classes to prod did not work. No delete option appeared, it just loaded all the other classes again. Any other suggestions on how to delete a class from Prod without using eclipse or some other tool?
I was using Eclipse/Force.com to set the "Deleted" flag then would "Deploy" to production. Unfortunately, something went wonky with the plugin recently and I was no longer able to connect (and yes, I verified all of my credentials). The Force.com deploy process always seemed a little iffy to begin with and I think Salesforce is moving away from Force.com anyway (based on recent webcasts), so...
That prompted me to start looking for a different/better way to delete Apex classes. One thing I noticed is that Apex classes that don't have any methods don't show up in "Setup -> Apex Classes", so deleting them from there is out (I always comment out the entire class before removing it).
Then I ran across an article on setting up MavensMate with Sublime Text (https://www.mstsolutions.com/blog/content/sublime-text-3-mavensmate-forcecom-development) (VS Code will also work). After getting that all set up, I am now able to set the "Deleted" flag on the metadata file and just save it, which automatically deploys the change to production. There's a bit of a lag to deploy, but it is a really simple process.
As Bob suggested, you should first delete it from your sand box using force.com IDE.
Below are the steps:
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.
Note: if you have any test class for the class that you are deleting make sure you do the same like above and then select those 2 classes for final deployment.
Hope it helps.
Sales4ce
All Answers
You need to delete it from your classes directory on your sandbox and then deploy your classes directory to production. In the deployment window you should then see the option to delete the classes from the target organization.
As Bob suggested, you should first delete it from your sand box using force.com IDE.
Below are the steps:
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.
Note: if you have any test class for the class that you are deleting make sure you do the same like above and then select those 2 classes for final deployment.
Hope it helps.
Sales4ce
This process doesn't seem to work for me, when I follow the numbered steps, instead of a delete option, I get an update option.
Any other suggestions. This is one of the most difficult tasks in all of Apex development.
I usually delete the class from my sandbox and then deploy the whole of the classes directory. This picks up the fact that my sandbox has deleted classes compared to production and the classes appear as delete options.
Of course I usually then uncheck every other class, but that's optional depending on if your sandbox is different to production.
thanks its work for me.
Please visit http://www.consleague.com/blog/?p=25 to know how to do it from Command line using Ant Deploy Process
Another easy way to do it is:
1. Use IDE to create a new project and download all classes from production
2. In the class you want to delete, open the metadata item and change the status to deleted.
3. save to server, and boom, gone.
@Starz26
Sweet! That works great! BY FAR the easiest way!
Awesome... Thanks!
@Starz26: It worked like a charm.
Sweet! Somebody get this guy (@Starz26) a medal.
Thanks, it works.
This method worked for me.
Can any body let me know how i can delete those classes?
Starz26 can you please help me?
Thanks in advance.
I first tried the shortcut method of connecting directly to production and setting the XML status to Deleted, and it worked on my test classes but refused to delete anything else. Of course this caused every deployment thereafter to fail because I no longer had sufficient test coverage on production. I had to gather all that code from an old sandbox, redeploy it to production, and then go through the proper steps outlined above. And it worked flawlessly.
TL/DR: Don't bother with the shortcut, it will cause more problems than it solves.
-
I'm experiencing classes refusing to accept delete saving to production server because of missing dependent classes.
-
Cannot deploy from sandbox, because code coverage is below 75% (Many thanks to my shoddy coders)
-
Eclipse kepler has to be the buggiest most broken IDE I've ever tried.
It seems I'm either FUBAR or SOL. Take your pick.1. Just Right Click the class in IDE which you want to delete.
2. It will ask for a confirmation "Are you sure you want to delete file "classname" ?" Click "Yes".
3. Next confirmation will ask you "The requested operation will only delete the resource locally. Would you also like the resource to be deleted from the server?"
4. Click yes and the class is deleted from SFDC instance.
File Name: classes/AttachLogTallies.cls
Full Name: AttachLogTallies
Action: NO ACTION
Result: SUCCESS
Problem: n/a
File Name: package.xml
Full Name: package.xml
Action: UPDATED
Result: SUCCESS
Problem: n/a
There really needs to be a better way to delete. Maybe we should have "packages" that can be installed and uninstalled.
I came across your steps, after changing the status from Active to Deleted, I don't have option to Save to server/Deploy to Server for the particular Apex class which is under the installed package. Any help here it would be great.
Thanks in advance.
Vinod kumar
I was using Eclipse/Force.com to set the "Deleted" flag then would "Deploy" to production. Unfortunately, something went wonky with the plugin recently and I was no longer able to connect (and yes, I verified all of my credentials). The Force.com deploy process always seemed a little iffy to begin with and I think Salesforce is moving away from Force.com anyway (based on recent webcasts), so...
That prompted me to start looking for a different/better way to delete Apex classes. One thing I noticed is that Apex classes that don't have any methods don't show up in "Setup -> Apex Classes", so deleting them from there is out (I always comment out the entire class before removing it).
Then I ran across an article on setting up MavensMate with Sublime Text (https://www.mstsolutions.com/blog/content/sublime-text-3-mavensmate-forcecom-development) (VS Code will also work). After getting that all set up, I am now able to set the "Deleted" flag on the metadata file and just save it, which automatically deploys the change to production. There's a bit of a lag to deploy, but it is a really simple process.
I hope this helps somebody.
I believe Salesforce is moving towards a .NET Code solution but I'm not sure if it is viable yet.