• Lee Won
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi
I am getting following error when i am trying to create custom object
System.Web.Services.Protocols.SoapHeaderException: null: Must specify a nameField of type Text or AutoNumber

my code is as follows:

metaforce.CustomObject co = new metaforce.CustomObject();
                co.deploymentStatus = metaforce.DeploymentStatus.Deployed;
                co.deploymentStatusSpecified = true;
                co.description = "My Custom Object created from .NET";
                co.fullName = "DotNetCustomObject__c";
                co.label = "DotNet Custom Object";
                co.pluralLabel = "DotNet Custom Objects";
                co.sharingModel = metaforce.SharingModel.ReadWrite;
                co.sharingModelSpecified = true;
                co.enableActivities = true;


                CustomField nf = new CustomField();
                nf.type=FieldType.Text;
                nf.label= "DotNetCustomObject__c"+" Name";
                co.nameField = nf;
                SaveResult[] results = ms.createMetadata(new metaforce.Metadata[] { co });
Hi
I am getting following error when i am trying to create custom object
System.Web.Services.Protocols.SoapHeaderException: null: Must specify a nameField of type Text or AutoNumber

my code is as follows:

metaforce.CustomObject co = new metaforce.CustomObject();
                co.deploymentStatus = metaforce.DeploymentStatus.Deployed;
                co.deploymentStatusSpecified = true;
                co.description = "My Custom Object created from .NET";
                co.fullName = "DotNetCustomObject__c";
                co.label = "DotNet Custom Object";
                co.pluralLabel = "DotNet Custom Objects";
                co.sharingModel = metaforce.SharingModel.ReadWrite;
                co.sharingModelSpecified = true;
                co.enableActivities = true;


                CustomField nf = new CustomField();
                nf.type=FieldType.Text;
                nf.label= "DotNetCustomObject__c"+" Name";
                co.nameField = nf;
                SaveResult[] results = ms.createMetadata(new metaforce.Metadata[] { co });
As of API30 update, we no longer have visibility on CustomFields that are created using the Metadata API. Looking at the Metadata API Developer's Guide v30.0 for ProfileFieldLevelSecurity, this seems to be an intentional change for API30: new CustomFields have their 'readable' flag set to false by default.

This is causing an issue when we attempt to list the fields for the related object: the new CustomFields are not returned as part of the DescribeSObjectResult data, as they are now defaulting to being hidden for all profiles.

This impacts our testing / QA environments, as they need to create new objects/fields and access them programmatically.

Is there a simple mechanism for forcing the new CustomField(s) to be flagged as visible, either for all profiles or for the current profile, when creating the field(s)?

What is the most efficient way to make CustomFields be visible when creating them?