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
whitfty1whitfty1 

Insert Lead from Flex (Auto Generate Lead.Id)

I have successfully been able to run select statements from Flex accessing our SF account.  Now I need to create a lead and it seems to be trying to work (see code below) but I keep getting an error stating the id value must be added.  Not sure how to auto-generate this id.  Has anyone done this?

 

 

"var so:SObject = new SObject("Lead");

so.FirstName = myfirstname;

so.LastName = mylastname

so.Email = myemail;

so.Company = mycompany;

etc....

 

aSo.push(so);

 

force.update(aSo,

new AsyncResponder(

function updateResults(obj:Object):void {

if (obj[0].success == false) {

mx.controls.Alert.show(obj[0].errors[0].message.toString(),"Error updating contact"); }

else {

// do something like update the collection

Alert.show("Check it out");

}

 

}, queryFaultHandler

)

);

"

Message Edited by whitfty1 on 10-22-2009 10:55 AM
Best Answer chosen by Admin (Salesforce Developers) 
whitfty1whitfty1

Can't believe that I overlooked this.  I have figured the problem out, I just needed to change this bit of code:

 

 " 

force.update(aSo,

new AsyncResponder(

function updateResults(obj:Object):void { "

... etc

 

TO:

 

force.create(aSo,

new AsyncResponder(

function updateResults(obj:Object):void {