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
L0t3kL0t3k 

Newbie Question about Inserting a Lead

I'll say right away, I'm just beginning to work with Salesforce, as we're evaluating now.

I've gotten the enterprise wsdl imported, and have managed to created a binding to SF, but I'm having trouble trying to add a lead.

This is what I have in that particular function...

Code:
        Dim newLead As New ApexAPI.Lead
Dim createdUser As New ApexAPI.User
createdUser.Username = "ttesterson@nowhere.com"
Dim ownerUser As New ApexAPI.Name
ownerUser.FirstName = "Test"
ownerUser.LastName = "Testerson"

newLead.FirstName = "James"
newLead.LastName = "Dean"
 newLead.Company = "UltraMegaMart"
newLead.LeadSource = "Web" newLead.CreatedBy = createdUser newLead.Owner = ownerUser

 Now I want to commit this object as a lead in our salesforce database.  I've seen examples of doing this with the partner wsdl, but not the enterprise one.  Unfortunately, I have no idea how to actually insert this lead.  A quick pointer would be much appreciated!

SuperfellSuperfell
use the create call. Really, you should start by walking through the .NET quick start, which covers all this.
L0t3kL0t3k
I assumed create does the trick, but it takes an sObject object parameter, which my Lead object, obviously, is not.  I suppose I should have been more specific, I figure I'm trying to turn a Lead object into an sObject so that I can insert it.  I expected there to be a method for this, but haven't found it.

As for the quickstarts, I downloaded all the vb sample code and looked through it but it saves contacts and accounts (no leads) as xml elements and uses partner wsdl specific actions that are not available to me through the enterprise wsdl.  I'm a bit twisted around I suppose... I expected a save lead function, or something to convert a Lead object into the sObject type.

Where can I find this .Net quick start, if it's something different from the Sample Code or the Recorded Webinar?  As I mentioned the sample code does something different, and unfortunately someone botched production on the posted webinar (check out the actual demo part).  Just a little lost here.

Thanks for responding... I appreciate it!

SuperfellSuperfell
https://wiki.apexdevnet.com/index.php/API#.NET

Create / Update / Delete work exactly the same for every data type. Your Lead object is an Sobject, SObject is its base class, so you can just do

SObject [] toCreate = new SObject [] { newLead };
SaveResult [] sr = binding.create(toCreate);

L0t3kL0t3k

Gotcha.  I've never actually worked with base classes like this before, so I had no idea.  Obviously, I'm not a programmer by trade. :)

Anyway, I wrote that out as:

    Dim toCreate() As sObject = New sObject() {newLead}
    Dim sr() As SaveResult = myBinding.create(toCreate)

And it appears to be working properly, except for a complaint about "INVALID_TYPE: Must send a concrete entity type."  But I expect I'll be able to work it out from here.

Thanks again Simon!

L0t3kL0t3k
Yeah, had something to do with the way I tried to assign an owner and creator.  I commented those out and let it handle those fields with default rules and it worked fine.  Now, on to the next problem!