I have imported a few things from Excel file, using Metadata API namely Profiles, Roles, Fls,Custom Objects, Custom fields. To achieve rollback I want to delete all of them if insertion of any of them fails. I am able to delete Custom objects and custom fields, but unable to delete roles and profiles. Can anybody tell me any possible way for that using apex code? What are the metadata types that can't be deleted using apex Code?


Cant say this is an answer but surely will help you in situation to understand more

Go through this

OR See if you can found your solution/more info here - very nice answer -- Using Meta data api in apex


If you want to make a deployment that rolls back properly in case of failure, you should deploy it all in one ZIP like any other deployment. Unfortunately this is not something you can do entirely from Apex alone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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