I want to delete the unmanaged code present in my org using salesforce migration tool.While undeploying the components i'm facing a lot of errors like you cannot delete the following components as they are referred in some other components. eg: xyz page is linked with some Custom tab or link . The dependency checker in salesforce doesn't seem to look beyond 1 level deep.

I cannot go and remove every dependency manually.Is there anyway undeployment can be achieved using destructivechanges.xml? Or is there any hierarchy which i should follow to delete the components in multiple steps.


This is a tricky one, and you are right: it's a very tedious process.

The way I have done it last time was starting from a base destructiveChanges and iterating over on every error, by adding a components based on the failure/output for that deployment attempt. If I remember correctly the order looked something like:

1) Pages 2) Components 3) Apex Classes 4) Workflows 5) Fields

If you do this and want to keep track of your final sequence please let me know. I'd like to write some script to automate it at some point.

  • hey..! thanks for the reply.But mainly i was facing errors while undeploying pages which are linked with custom buttons or links, fields which are referred in some custom formula fields. – nh972 Nov 24 '15 at 8:54
  • I want to remove those dependencies using my script.Don't want to remove the buttons first and thn delete the pages using script. – nh972 Nov 24 '15 at 8:58
  • You are right. I am afraid removal of custom links/buttons cannot be easily scripted. I suggest to get rid of them all first, then you can iterate over the destructiveChanges.xml – Lorenzo Frattini Nov 24 '15 at 8:59
  • while undeploying the objects, I got this error objects/Loan_Product__c.object -- Error: This custom field is referenced elsewhere in salesforce.com. : Filtered Lookup. This custom object definition is referenced elsewhere in salesforce.com. Remove the usage and try again. : Workflow Rule-01Q15000000F5P1. – nh972 Nov 25 '15 at 7:40
  • Do you have any idea how this can be handled ? – nh972 Nov 25 '15 at 7:40

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.