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
Scooter429Scooter429 

Using the MetaData API with Custom Fields

1.  Can you please clarify the process for adding / updating / deleting a custom field other than the standard name field in a custom object.  The documentation states:"You must specify every relevant field in this object whenever you create or update it, especially fullName. You cannot update a single field on the object."  I am trying to figure out which fields are actually mandatory.

2.  Related question.  Assume that using the supplied examples I've already programatically created a custom object with a standard name field.  In a separate transaction I would now like to add a custom text field.  Should I use binding.create with a custom field or binding.update with a custom object?  

Thank you.

SuperfellSuperfell
1) the required fields depend on what the field type is, probably the quickest way to work it out is to look at the UI for creating a custom field, and see which properties you get to set for the relevant field type.

2) customField.
Scooter429Scooter429
Simon, thanks for your response.   So with respect to point 2, if the guidance is to do a binding.create how do I specify the "parent" object?

Code:
CustomField nf = new CustomField();
nf.setType(FieldType.Text);
nf.setLabel("New Field Name");

// WHAT GOES HERE TO TELL SFDC which Object owns this field?

AsyncResult[] ars = stub.create(new Metadata[] { nf } );


 

SuperfellSuperfell
the fullName should include the object name, e.g.

nf.setFullName("Account.tasty__c");