How to retrieve customFields on standard objects using Ant Migration Tool


I’m trying to reset a dev org by using this ant script.

Most part of the customisations added by default are removed. However, I’m not being able to retrieve custom fields on Opportunity, Account and other standard objects.

I’m using this to get customfields :


And this to get standard objects:


I’ve also tried:






How can I retrieve custom fields on standard object on ant migration tool?


As per the documentation the CustomField metadata type does not support wildcards sadly. You can access Custom Fields on Standard Objects by using the CustomObject metadata type as described here against specific Standard Objects. Then parse the .object file to build your destructiveChanges.xml file. Finally you can also use the sf:listMetadata task to download a list of all custom fields and then filter locally for Standard objects.


You might also be interested in an open-source undeploy Ant target published here, that wraps most of what i suspect your trying to develop up into a single Ant target. Sadly Salesforce do not yet give us a ‘clean my org’ task, so we build our own!

Source : Link , Question Author : Martin Borthiry , Answer Author : Andrew Fawcett

Leave a Comment