[SalesForce] Ant Migration Tool deleting objects with Rollup Summaries

I attended the Dreamforce '12 session Team Development and Release Management for ISVs and one segment of the session was about the tools FinancialForce use for blanking an org before deploying a fresh set of metadata.

The github repo with all the resources is here. These are terrific resources and have really given me a head start implementing this internally.

My problem is, I think the object structure of our application is too complicated to be deleted through the metadata api. The delete seems to failing because of Master Detail relationships and rollup summaries. To further complicate matters the rollups span 3 objects
e.g Parent-{Child-{Grandchild where the parent rolls up a child-{grandchild rollup field. The implementation is rolling up the earliest date of the grandchildren onto the parent.

My question is, has anyone been able to use the ant migration tool to delete objects with rollup summaries? Or is my problem more sinister because of the error "An unknown exception has occurred."

Here is the debug log from the migration tool:

/var/lib/jenkins/build-tools/undeploy.xml:74: FAILURES:

Error: objects/Parent_c.object(Parent_c):An unknown exception has occurred.

Error: objects/Grandchild_c.object(Grandchild_c):This custom object is summarized by a field in another object. Remove the usage and try again. : Child Custom Fields: End (Rollup). This custom object is summarized by a field in another object. Remove the usage and try again. : Child Custom Fields: Start (Rollup).

Error: objects/Work_Type__c.object(Work_Type__c):An unknown exception has occurred.

Error: objects/Child_c.object(Child_c):This custom object is summarized by a field in another object. Remove the usage and try again. : Parent Custom Fields: Parent End Date. This custom object is summarized by a field in another object. Remove the usage and try again. : Parent Custom Fields: Parent Start Date.

Error: pages/child_view_override.page(parent_phase_view_override):The page you have tried to delete is currently being referenced by a page, custom link, button, web tab, dashboard, SoftPhone layout or custom sidebar component. Please delete the reference before deleting the page.

Best Answer

I did encounter the dreaded "An unknown exception has occurred" too; but it was when using related lookup filters which used reference fields to lookup to a 3rd object. The dependency checker in salesforce doenst seem to look beyound 1 level deep. I logged a case with them, which they accepted as an issue, are are trying to resolve.

My solution (i've not yet implemented) was to add logic in the scripts first step that edits page layouts and deploys them back prior to delete, to also clean up various things from .object files first too (related lookup filters, and perhaps rollup summary fields under simliar conditions). Then they undeployment should be allowed, this in principle though is very tricky due to the code possibly referencing these fields. So it thus is also necerssary to edit every class, trigger, page and empty them out and deploy too. I have some logic to do this, and will try and update the git hub repo soon.

Eric Wilcox (developer of the undeploy script)