I am using MetaData API to create the custom object and custom field, but problem is how to insert the data into that Custom object ( Entity ) ,,eg I have created one Custom object Employee and there are some fields in this object like name, address, phone and Email,, but problem is I have to update the Enterprise WSDL than only I got this

Employee objEmployee = new Employee();

I dont have liberty to update the WSDL everytime because my customer can make number of custom objects at runtime with custom fields. Someone told me that use the Partner WSDL but how still I am not getting the class of Custom object.......

Please help with the code I am new with SalesForce,, like how to create the custom object and custom field,, than insert data inot that object at runtime,,,,

I tried lots of things but no help!!!

Regards Raman

This is my code

WalkThrough.Partner.sObject myobj = new WalkThrough.Partner.sObject();
            System.Xml.XmlElement[] objFields = new System.Xml.XmlElement[6];

            // Create the contact's fields
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            objFields [0] = doc.CreateElement("label");
            objFields [0].InnerText = "EmployeePartner";
            objFields [1] = doc.CreateElement("pluralLabel");
            objFields [1].InnerText = "EmployeePartners";

            myobj.type = "Employeepartner__c";
            myobj.Any = objFields ;

            // Add this sObject to an array
            WalkThrough.Partner.sObject[] objList = new WalkThrough.Partner.sObject[1];
            objList [0] = myobj;

            // Make a create call and pass it the array of sObjects 
            WalkThrough.Partner.SaveResult[] results = binding.create(objList );

But its throwing exception

INVALID_TYPE: sObject type 'Employeepartner__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names

  • 1
    Welcome to SFSE, Raman. You should do some research on using the available APIs to create objects and insert data because your question is very broad and does not show much research.
    – Mike Chale
    May 28, 2013 at 11:38
  • Hi Mike :: I tried lot but did not get so much ,, they are saying like use the APEX code...
    – Raman
    May 28, 2013 at 12:28
  • I understand that learning a new system can be daunting, but in order for this site to be effective questions need to be researched. Please at least go through some of the many tutorials Salesforce makes available for working with the SOAP and REST APIs.
    – Mike Chale
    May 28, 2013 at 12:45
  • I think you have two requirements for which you require two separate Salesforce API's / WSDL's imported into your .Net application. A) In order to create an Custom Object and define its fields you need to use the Metadata API and the 'deploy' operation. B) In order to insert records into that Custom Object you need to use the Partner API (as this is a dynamic API). Your code appears to be mixed above, I can see your trying to define aspects of what looks like the CustomObject type (from the Metadata API) and pass it to the 'create' (record) operation on the Partner API. May 28, 2013 at 17:07
  • Hi Andrew ! thanks for the reply ,, Means you are saying we can not create the custom objects by Partner WSDL/API,, for that I should use MetaData API and to insert the records into custom object I should use Partner API,, Right ???
    – Raman
    May 29, 2013 at 6:16

1 Answer 1


Instead of using the enterprise wsdl you could use the partner wsdl then your code looks a bit different and the object itself is not in the wsdl.

in the partner wsdl you first need to initiate your object like this

SObject mycustomobject = new SObject(); mycustomobject.setType("customobject__c");

a good reference here http://www.salesforce.com/us/developer/docs/api/Content/sample_update_call.htm#topic-title

  • Thanks for the answer Sven :: Can you please,, provide me code or any link so that I can find out how to create custom object by Partner WSDL.. everywhere the example of "SObject mycustomobject = new SObject(); mycustomobject.setType("customobject__c"); " is for standard object like Account contact and lead not for custom object Regards Raman
    – Raman
    May 28, 2013 at 12:27
  • yes but with __c you can refer to a custom object also. see this blog post on the salesforce community boards.developerforce.com/t5/NET-Development/… May 28, 2013 at 12:36
  • I added one code into my question please look into it,, Still not able to add the custom object by Partner WSDL
    – Raman
    May 28, 2013 at 13:02
  • Hi Sven ,, thanks for all help,, I have got my solution now
    – Raman
    May 30, 2013 at 4:36

You must log in to answer this question.

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