I was having the same issue.
And finally solved it out !
If you miss the field length it won't work, look at this:
metaforce.CustomField nf = new metaforce.CustomField()
nf.label = "Name Test";
nf.fullName = "Name Field";
nf.type = daTest.metaforce.FieldType.Text;
nf.typeSpecified = true;
co.nameField = nf;
metaforce.CustomField myfield = new metaforce.CustomField();
myfield.label = "CustomField";
myfield.fullName = "CustomField__c";
myfield.type = daTest.metaforce.FieldType.Text;
myfield.length = 30;
metaforce.CustomField myfield = new metaforce.CustomField();
myfield.label = "CustomField";
myfield.fullName = "CustomField__c";
myfield.type = daTest.metaforce.FieldType.Text;
myfield.length = 30;
myfield.lengthSpecified = true;
myfield.typeSpecified = true;
metaforce.CustomField myfieldb = new metaforce.CustomField(); myfieldb.label = "CustomFieldb"; myfieldb.fullName = "CustomFieldb__c"; myfieldb.type = daTest.metaforce.FieldType.Text; myfieldb.length = 30; myfieldb.lengthSpecified = true; myfieldb.typeSpecified = true;
metaforce.CustomField myfieldc = new metaforce.CustomField(); myfieldc.label = "from_ui"; myfieldc.fullName = "from_ui__c"; myfieldc.type = daTest.metaforce.FieldType.Text; myfieldc.length = 30; myfieldc.lengthSpecified = true; myfieldc.typeSpecified = true; myfieldc.required = false;
co.fields = new metaforce.CustomField[] { myfield, myfieldb, myfieldc } ;
myfield.lengthSpecified = true; myfield.typeSpecified = true;metaforce.CustomField myfieldb = new metaforce.CustomField(); myfieldb.label = "CustomFieldb"; myfieldb.fullName = "CustomFieldb__c"; myfieldb.type = daTest.metaforce.FieldType.Text; myfieldb.length = 30; myfieldb.lengthSpecified = true; myfieldb.typeSpecified = true;
metaforce.CustomField myfieldc = new metaforce.CustomField(); myfieldc.label = "from_ui"; myfieldc.fullName = "from_ui__c"; myfieldc.type = daTest.metaforce.FieldType.Text; myfieldc.length = 30; myfieldc.lengthSpecified = true; myfieldc.typeSpecified = true; myfieldc.required = false;
co.fields = new metaforce.CustomField[] { myfield, myfieldb, myfieldc } ;
That works for me !