5

Is it possible to delete an apex class or apex trigger using Metadata API? Please guide. I tried using https://github.com/financialforcedev/apex-mdapi but it did not work.

3 Answers 3

2

That API might not allow it, but certainly you can delete files from the server using the metadata api, the deploy call, and a destructive changes file.

In terms of doing it from Apex, you can do it from the metadata api (though this would be the more complex way) or the partner api. Based on your other comments, it seems like you are talking about doing this in the context of a visualforce page, in which case I would recommend just using the ajax toolkit and the deleteIds call.

1

From the README on the project you linked to:

Note: The CRUD operations do not support Apex Class or Apex Trigger components sadly, this is a API restriction and not an issue with calling from Apex as such.

You cannot delete Apex Classes or Triggers from the Metadata API.

2
  • I read the README file. Is there any way we can delete Apex classes and Triggers using Apex?
    – Swati
    Commented Jan 21, 2014 at 13:05
  • @AndrewFawcett : Is there any way we can delete Apex classes and Triggers using Apex? Please guide.
    – Swati
    Commented Jan 21, 2014 at 13:08
0

You should be able to use 'Tooling API' instead. Please have a look at this documentation

http://www.salesforce.com/us/developer/docs/api_toolingpre/api_tooling.pdf

1
  • can you provide more details / references in your answer on how to achieve this with the tooling api ? may be a sample code will be good. Commented Sep 22, 2014 at 0:37

You must log in to answer this question.

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