11

I want to delete a previously deployed class. Is there a way to do it strictly through the web interface (sandbox and/or production)?

I'm kind of surprised that something like this isn't at least slightly easier to do.

When looking for an answer every place explains how to do it through the IDE but I don't have access to a security token that can do that, I only have access to their sandbox and production accounts through the "grant login" feature (custom work on a client's system).

1
  • 1
    I don't know how the grant login feature works, but could you temporarily add you IP address as trusted so that you don't require the security token? Alternatively, all you really need for API access is a Session ID and Server URL. You could hijack those and then bootstrap them into the correct API calls. Commented Sep 3, 2012 at 4:47

2 Answers 2

15

I am 99.999% sure that you cannot delete the class through the Salesforce Web interface. You cannot do it through Changesets.

I believe that you have to use something backed by the metadata API such as the Force.com IDE or the Ant Migration tool with a destructiveChanges file. That is no help for you, however, since you'd need the token in your situation.

3
  • 1
    Or create the destructiveChanges file and provide it to the client with instructions.
    – Mike Chale
    Commented Sep 2, 2012 at 23:24
  • @MikeChale - That's a good idea. Along those same lines, the client could whitelist your IP...would that negate the need for the token? Commented Sep 3, 2012 at 13:05
  • 1
    Yes, it would negate the token. We have an API user account on a whitelisted server and it does not require the token.
    – Mike Chale
    Commented Sep 3, 2012 at 15:36
6

I guess you can do that with the Developer Workbench.

Steps:

  1. Navigate to Rest Explorer
  2. Select Delete
  3. call /services/data/v34.0/tooling/sobjects/ApexClass/{Class Id}

Also you can query for desire class by Id: /services/data/v34.0/tooling/query/?q=Select+Id+from+ApexClass+Where+Id='{Class Id}'

or query by name: /services/data/v34.0/tooling/query/?q=Select+Id,Name+from+ApexClass+Where+Name='{name of the class}'

3
  • 1
    No, I don't believe this can be achieved. I return this error: ' [ { "message" : "Cannot complete this operation. Cannot delete classes/triggers in production. Use compileAndTest verb to delete. : null ", "errorCode" : "DEPENDENCY_EXISTS", "fields" : [ ] } ]' Commented Mar 8, 2016 at 11:35
  • Hey @AndyHitchings were you able to delete the class using metadata API such as the Force.com IDE or the Ant Migration tool , one of these methods?
    – Sashko
    Commented Mar 9, 2016 at 22:55
  • 1
    Hey @AlexBar I was able to delete the class via Workbench in the end using the methodology outlined by sfdcfox here: salesforce.stackexchange.com/questions/46612/… Commented Mar 10, 2016 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .