function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JvalleeJvallee 

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:

http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_listview.htm

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.
SuperfellSuperfell
You need to set the fullName of the field to Lead.newFieldName__c, See this example.

http://www.pocketsoap.com/weblog/2008/05/1811.html
JvalleeJvallee
Thanks, this makes perfect sense now.
Suraj Tripathi 47Suraj Tripathi 47
Hi Jvallee,

You can create a custom field in a standard object like this:
Go to setup->Select Object Manager->Choose Object Name->Click field and relationships->New->choose type->Enter Name of field->Save.


If you find your Solution then mark this as the best answer.

Thank you!

Regards,
Suraj Tripathi