+ Start a Discussion
Mike LeachMike Leach 

Retrieving Custom Fields on Standard Objects

How do I retrieve all custom fields on a standard object using the Migration Toolkit Metadata API?


The migration tool guide provides this markup for retrieving standard objects (SO), but indicates that custom fields on SOs must be retrieved individually.



<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

I'm looking for more of a wildcard approach to retrieve all fields. My goal is to run an Ant script daily to retrieve and backup all metadata. Is this possible?



There's no wildcard for custom fields. You have to name each one individually. To automate the process, you could maybe use the describeMetadata call (http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_describe.htm) to populate your retrieve list.


And then use Ant scripts to find all fields with "*__c"? 


While I'm sure you are correct...this is ridiculous and a waste of time.  I don't understand why Salesforce doesn't support XML consistently between standard and custom objects.  Another why Salesforce makes it difficult for in-house developers to develop salesforce.com applications.  They want you to pay for appexchange apps.