11

Background

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 :

<types><members>*</members><name>CustomField</name></types>

And this to get standard objects:

<types><members>*</members><name>CustomObject</name></types>

I've also tried:

<types><members>Account.*</members><name>CustomField</name></types>

and

<types><members>Opportunity</members><name>CustomObject</name></types>

Unsuccessfully

Question

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

4 Answers 4

5

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.

     <sf:listMetadata 
        username="${sf.username}"
        password="${sf.password}"
        metadataType="CustomField"/>

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!

0
5

Fully naming the fields works e.g.:

<types>
    <members>Account.PayeeNameOverride1__c</members>
    <members>Account.PayeeNameOverride2__c</members>
    <members>Contact.JobDescriptionDate__c</members>
    <members>Contact.JobDescription__c</members>
    <name>CustomField</name>
</types>
4
  • Is there any way to make this more "generic" ? Commented Feb 10, 2014 at 9:33
  • We have no examples with wildcards...
    – Keith C
    Commented Feb 10, 2014 at 9:35
  • 1
    But, how do you retrieve the customfields if you don't know the names? Commented Feb 10, 2014 at 11:28
  • Sorry I didn't pick up the "reset a dev org" part of your question so I see where you are coming from now. You could write Java code that uses the meta-data API to find the field names and then wrap that in an Ant task that is called first and edits your package.xml. But just manually tracking the field names is simpler unless you are talking about hundreds of fields.
    – Keith C
    Commented Feb 10, 2014 at 11:46
2

If you want to extract all the custom field of say Accout object , then write atleast one custom field name of account object and then write * in the other member tag like this

<types>
        <members>*</members>
        <members>Contact.Level__c</members>
        <name>CustomField</name>
    </types>

This will extract all the custom field of account object.

And if you want to extract custom as well as standard field then go for this

<types>
        <members>Contact</members>
        <name>CustomObject</name>
    </types>

Hope it helps

1
  • 1
    I tried the first snippet, and only the specified field migrated. Commented Jan 25, 2019 at 15:58
0

If you want to extract particular fields.Then use this

<types>
<members>Case.EngineeringReqNumber__c</members>
<name>CustomField</name>
</types>
<types>
<members>Account</members>

Using the Force.com Migration Tool Constructing a Project Manifest

<name>CustomObject</name>
</types>

You must log in to answer this question.

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