6

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.

4 Answers 4

7

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)

3
  • Thank you Eric! I was very excited when I saw you had answered my question. Thanks again for the talk at Dreamforce. Commented Oct 6, 2012 at 6:53
  • On a similar note, If you are interested I have written an ant call for deleting workflow rules. It was frustrating to discover that rules, alerts, field updates etc need to be defined individually in the destructiveChanges.xml file Commented Oct 6, 2012 at 6:56
  • Did anything result of the case that was logged? It looks like there's still a problem with the dependency checker not being able to go more than one level deep. I have two roll-up summary fields, one which references the other, and I am not able to delete both of them in the same destructiveChanges.xml file. Commented Oct 6, 2015 at 20:27
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
2
  • I'm inclined to agree although I haven't reproduced the problem and also comment that it sucks you have to detect roll up fields, remove them, then remove the child objects. Makes things so very difficult. Commented Oct 5, 2012 at 2:21
  • It's even more complicated because the rollup fields are referenced in formulas, apex classes, fieldsets and other metadata, which means it's not as simple as just deleting the rollups. By the time the full dependency path is mapped out it ends up being almost all the metadata Commented Oct 5, 2012 at 3:34
0

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;"/>
    </fileset>
    <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"/>
  </xmltask>
</target>

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.

-3

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

You must log in to answer this question.

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