+ Start a Discussion

Creating Custom Field in Standard Object

I am working with the Metadata API, and am having trouble figuring out how to programmatically create a custom field to a standard object.  The only documentation that I have been able to find is:


The sample here is Java only and it has been a struggle to work with since the objects that I am working with are so different than the ones used in sample.  I want to add a custom field to the Lead standard object, but I'm not sure how to.

Based on the sample above, I believe I need to pass a complete object to the create function to get this to work, since if I pass just a custom field there is no property to associate the type that the field belongs to.  Therefore, I think that create will only work if I pass the standard object with the Custom Field.  Also, I'm not sure how to create an instance of a standard object with all of the properties populated.

Any help would be great.
You need to set the fullName of the field to Lead.newFieldName__c, See this example.

Thanks, this makes perfect sense now.