Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I cannot install Eclipse, even if I wanted to. It is not approved software for my org.

How can test classes be deleted from production, using deployments? There no 'active' checkbox when I am editing the classes in sandbox mode, so I can't just deactivate the test class, and i cant deploy a deleted class to prod... how the heck is this done?

I dont want to use ANT or special software. SF must have a native way to achieve this. And if not... then I am very disappointed in humanity.

share|improve this question
2  
lols one easy way is to comment out using /* at the start and */ at the end of the class, there by commenting out the complete class and deploy it using change sets (standard deploy mechanism provided by salesforce). Wish someone comes up with something better, but for now I am sure this solution should restore your faith in humanity :D –  rao Aug 11 at 21:03
    
Heh yeah that's what I ended up doing. Well actually i deleted all the contents of the test method for now. I found a knowledge article stating that IDE is the only way to fully delete them. –  DownstairsB Aug 11 at 21:14
    
@DownstairsB There's multiple ways to achieve your goals. You might want to revisit this question. –  sfdcfox Aug 11 at 21:59

3 Answers 3

up vote 7 down vote accepted

You can do this with only the software that comes installed with Windows/Linux/Mac. These instructions will be for Windows.

Create a Folder

Make a folder on your desktop. You'll want this so you can keep your files in order.

Create package.xml

Open Notepad (Start > Accessories > Notepad). Copy the following text into the text editor:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>30.0</version>
</Package>

Save this file as package.xml within the folder you created. NOTE: You have to change "Save as type" to "All files (*.*)", or Notepad will "helpfully" add a ".txt" extension that we don't want.

Create destructiveChanges.xml

Create a new file in Notepad (File > New). Copy the following text into your text editor:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>SomeTestClass</members>
        <name>ApexClass</name>
    </types>
    <version>30.0</version>
</Package>

Change SomeTestClass to the class you want to delete.

Save this file in the folder you created as destructiveChanges.xml (note the capital C in "changes"). Again, make sure that you saved it as "All files (*.*)".

At this point, you have two files in your folder. Open the folder, select both XML files, right-click, and choose "Send To > Compressed Folder". The default name is fine.

You're all set up at this point. Now, you just need to deploy the file.

Go to http://workbench.developerforce.com/, login using your production credentials, then choose "Migration > Deploy", upload your file, and confirm the process.

See this article (not mine: http://carvingintheclouds.blogspot.com/2013/12/deploying-destructive-changes-using.html) for some pictures and nice cloud-like palettes.

share|improve this answer
    
Interesting. I never played with the workbench before. Thanks! Maybe I can get away without installing Eclipse :) –  DownstairsB Aug 13 at 18:16

Here is a guide to deleting a class using the Force.com Migration Tool which uses Ant.

https://developer.salesforce.com/page/Propagating_Destructive_Changes

share|improve this answer
    
User "can't" install software, although using the migration tool isn't strictly an install (just unzipping), it's still extra software that IT might not like. Personally, that's what I'd do though. I like the migration tool. –  sfdcfox Aug 11 at 22:00
    
He said he can't install Eclipse, he didn't mention Ant / other command line tools. Ultimately it comes down to his companys IT policy and how literally he wants to take it. –  DavinC Aug 11 at 22:08
1  
"I dont want to use ANT or special software. SF must have a native way to achieve this." -- I think that this kind of suggests that OP can't or won't use Ant. –  sfdcfox Aug 11 at 22:15

Based on this post on tooling API:

http://intmist.wordpress.com/2014/03/09/force-com-tooling-api-create-apex-class-apex-trigger-dynamically-and-updatedelete-apex-trigger-apex-class-using-tooling-api-with-rest-api/

I tried deleting a class from my developer account and I was able to do it using workbench by just providing the class Id and using delete( Sys admin profile)

I am not sure if this would apply for your PRD org. Would be worth giving this a try.

enter image description here

Deleting a Apex Class:

// [Status=No Content, StatusCode=204] public void deleteApexClass() { HttpRequest req = createHttpRequest(endpoint+'/ApexClass/'+oid,'DELETE'); String responseJson = getResponse(req); // Store the result to do something }

share|improve this answer
    
Nice idea, rao, but I'm pretty sure the tooling API can't do this, because it's synchronous, and the user has to run all tests in order to change a file in prod. I don't have a production I can test this on, but you're welcome to actually try and do so. I'd love to see it be that easy, because it's far less complicated than my answer. –  sfdcfox Aug 11 at 22:01
    
@sfdcfox I tried it in my developer account on na14 instance and the class was deleted, is there any difference between an actual PRD instance compared to a developer PRD instance? –  rao Aug 11 at 22:04
2  
Class access is greatly relaxed compared to prod instances. In the workbench, you can also go to "info" > "metadata types & components" > "ApexClass", open "Components", then the class, then hover over "Id" and choose "delete". Same thing as the tooling API without having to remember the URL. –  sfdcfox Aug 11 at 22:06
    
I do not have access to a PRD org to test this too. I was not sure if this would work in an actual PRD org so I had the disclaimer asking the OP to give it a try. –  rao Aug 11 at 22:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.