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
Developer SurveypalDeveloper Surveypal 

Custom field creation with Metadata API

Hi, 

I've been working with the Meta API for few days and noticed that my custom fields created via API are not visible in the "Describe" resource of the REST API "/services/data/v38.0/sobjects/MyCustomObject__c/describe" however, I can see the custom fields created in the Setup -> Create -> Custom objects view inside my salesforce instance. Is there some update TTL for this type of changes? or there is some attributes in the Custom Field that needs to be set to enable it. Or it is just not possible to use REST API and META API together?

I am using the JAVA api library:
com.force.apiforce-metadata-api-38.0.0

And adding custom field code is the following (simplified):
CustomField field = new CustomField(); 
field.setType(FieldType.Text); 
field.setDescription(description); 
field.setLabel("answerid"); 
field.setFullName("answerid__c"); 
field.setLength(lenght);

customObject.setFields(new CustomField[] {field});
UpsertResult[] results = metadataConnection.upsertMetadata(new Metadata[]{ customObject });
It returns a success result, and as I commented, I able to see the field in the tool, however, I cannot use the field when creating instances of the custom object, and it does not show up in the REST API "describe" resource of my custom object.

Is there something I am missing ??
 
Daniel BallingerDaniel Ballinger
It will likely be field level security (https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/admin_fls.htm). While the profile of the user can create the field, they can't then access it for queries.