Find your content:

Search form

You are here

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/ 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.

Attribution to: Daniel Blackhall

Possible Suggestion/Solution #1

The debug log mentions the that your object is referenced, so you probably need to do this in batches:

  1. Delete the roll up summaries and other references to the related lists
  2. Delete the grandchildren
  3. Delete the children
  4. Delete the parent

Attribution to: Mike Chale

Possible Suggestion/Solution #2

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)

Attribution to: Eric Wilcox

Possible Suggestion/Solution #3

I wrote a new task which changes all Rollup summary fields to count type, and removes any filter criteria. Count-type rollup summaries don't have any sort of dependency on other fields and can't be chained together. After deploying them as count-type, they can be easily deleted.

<target name="removeFieldDependencies">
  <xmltask todir="./${stage.dir}/deploy/objects">
    <fileset dir="./${stage.dir}/objects/" includes="*.object" excludes="*__c.object">
        <contains text="&lt;type&gt;Summary&lt;/type&gt;"/>
    <remove path="/:CustomObject/*[not(self:::fields)]"/>
    <remove path="/:CustomObject/:fields[not(:type/text() = 'Summary')]"/>
    <remove path="/:CustomObject/:fields/:summaryFilterItems"/>
    <remove path="/:CustomObject/:fields/:summarizedField"/>
    <replace path="/:CustomObject/:fields/:summaryOperation/text()" withtext="count"/>

To utilize this you must pull down the Custom Objects inside the generatePackagePrePurge target by modifying what is being echo'd into package.xml. You'll also need to actually call this target with antcall. I have it as the last line of the generatePrePurgeMembers target in undeploy.xml.

Attribution to: frontendloader

Possible Suggestion/Solution #4

When you remove the roll up summary fields it can not totally removed into the salesforce platform so you must go to your custom objects -> deleted objects -> crush your roll up summary field. Enjoy.. Nejib

Attribution to: Nejib essouri
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content