+ Start a Discussion

create a lead from Contact Box using jquery

So I have a "Contact Us" box on a webpage I'm building, and I need to take the inputs and create a lead from them. Does anyone know how to create a lead? I can save all the info but it wont let me fully create the new Lead, I think I have to give it a new ID somehow. 


    var updated = [];
                    var cform = new sforce.SObject("Lead");
                    cform.Name = n;
                    cform.Company = c;
                    cform.Email = e;
                    cform.Description = r;
                    result = sforce.connection.insert(updated);


so I'm trying to set the cfrom lead object as a new lead and insert it into our salesforce database, but it's not working. I also tried 


result = sforce.connection.update(updated);


but no go. Any help would be appreciated


"It's not working" is not enough info for anyone to help you.


Install firebug, and tell us your error.


when i click my "submit" button that activates the javascript, it runs everything up to the "result = sforce.connection.insert(updated);" section, and that's where it fails. If I run it with the insert call, it gives me this


"71 Uncaught TypeError: Object [object Object] has no method "insert"


And when I run it calling update instead of insert, like this "result = sforce.connection.update(updated);", there is no error, but it doesn't create a lead and it doesn't call the alert in the code. My best guess is that there has to be a lead ID created before you can save a new lead, but I don't know how one would go about doing that. Of course that could be totally off. So if you know a better way to create a new lead from the submitted form data, let me know