1

I get this error id (1417884933-3641 (-2142224028)) when i try to use the Metadata API(.Net) to create a custom object with fields

This is my sample code

         CustomObject co = new CustomObject();
         co.deploymentStatus = DeploymentStatus.Deployed;
         co.deploymentStatusSpecified = true;
         co.enableActivities = true;
         co.description = objectName;
         co.fullName = "TestObj__c"
         co.label = "TestObj";
         co.pluralLabel = "TestObjs";
         co.sharingModel = SharingModel.ReadWrite;
         co.sharingModelSpecified = true;

         CustomField nameField = new CustomField();
         nameField.fullName = "TestObj Name"
         nameField.type = FieldType.Text;
         nameField.typeSpecified = true;
         nameField.label = "Name Field"
         co.nameField = nameField;

         CustomField customField1 = new CustomField();
         customField1.fullName = "TestObj__c.TestField__c";
         customField1.type = FieldType.Text;
         customField1.typeSpecified = true;
         customField1.label = "Test Field";
         co.fields = new CustomField[] {  customField1 };

         SaveResult[] results = ms.createMetadata(new metaforce.Metadata[] { co });

It throws the exception at the createmetadata call

EDIT:- If i don't specify the custom field name as "TestObj__c.TestField__c" but do something like

customField1.fullName = "Test Field";

i don't get any exception and the custom object "TestObj" is created but there are no custom fields in the object

12
  • Do you have any other more descriptive error in your results list? I don't think anyone apart from Salesforce support will be able to help you resolve this problem based on what you've provided. See if you have anything in results.errors[0].message Dec 9, 2014 at 5:06
  • i don't get back the results object because the code throws at the createMetadata call....i have also posted on the salesforce dev community forum but posted here hoping that someone might be able to figure out mistakes in my sample code. Dec 9, 2014 at 5:10
  • Can you please add your API call in a try/catch block and debug the message? try { SaveResult[] results = ms.createMetadata(new metaforce.Metadata[] { co }); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } Dec 9, 2014 at 5:13
  • i did debug the exception...it's the same exact error message as the title of this question....and there is nothing else that is useful in the exception Dec 9, 2014 at 5:17
  • 1
    if u or anyone u know has access to the salesforce instance in which you are trying to create the object, then please enable & monitor the debug logs for the api account and see whats happening in salesforce side. Dec 9, 2014 at 5:17

3 Answers 3

3

whenever we get an error of this kind(with Error ID), the exception is caught by Salesforce across the Error ID. So for speedy resolution and understanding the exact issue, its a good practice to get in touch with SFDC Support and then move forward.

3
  • yeah i already did that..i just posted here hoping i might get lucky Dec 9, 2014 at 5:23
  • The error numbers aren't like Microsoft error numbers. They represent numerical entries in an internal logging system. The actual cause isn't exposed to outsiders.
    – sfdcfox
    Dec 9, 2014 at 6:51
  • 2
    Salesforce.com calls these "GACKS". Here is their writeup on it. developer.salesforce.com/blogs/engineering/2015/02/gack.html Mar 5, 2015 at 20:05
1

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; 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 !

0

If you r creating field along with Object then FullName of custom field should not contain "Custom object Name"

 customField1.fullName = "TestField__c"; 

If you create only field then only u need to write like this

customField1.fullName = "TestObj__c.TestField__c";

..

CustomObject co = new CustomObject();
             co.deploymentStatus = "Deployed";
             co.deploymentStatusSpecified = true;
             co.enableActivities = true;
             co.description = "objectName";
             co.fullName = "TestObj__c"
             co.label = "TestObj";
             co.pluralLabel = "TestObjs";
             co.sharingModel = "ReadWrite";
             co.sharingModelSpecified = true;

             CustomField nameField = new CustomField();
             nameField.type = 'CustomField';
             nameField.type_x = FieldType.Text;
             nameField.label = "Name Field"
             co.nameField = nameField;

             CustomField customField1 = new CustomField();
             customField1.fullName = "TestField__c";
             customField1.type = 'CustomField';
             customField1.type_x = FieldType.Text;
             customField1.typeSpecified = true;
             customField1.label = "Test Field";
             co.fields = new CustomField[] {  customField1 };

             SaveResult[] results = ms.createMetadata(new metaforce.Metadata[] { co });

I think this might be usefull for you if i am wrong then correct me.

3
  • 1
    i already tried this a while back....i don't get an exception but the custom field "TestField__c" doesn't get added to the custom object "TestObj__c" Feb 26, 2015 at 17:39
  • Its my mistake now please check above code
    – Atul
    Feb 27, 2015 at 12:49
  • what's type_x? i only see customfield.type ... Mar 3, 2015 at 4:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .