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
PauloPaulo 

retrieving salesforceid through api

How can I return the salesforce id from sales force when I create a new lead through a web application? So as soon as I do this:
 
<code>
 
// Add the account to an array of SObjects
Sforce.sObject[] records = new Sforce.sObject[] {sfLead};

// Invoke the create call, passing in the account properties and saving the results in a SaveResult object Sforce.SaveResult[] saveResults = binding.create(records);

</code>

Can salesforce return the id?

talanbtalanb
Paulo

Take a look at the value returned from the create call. You get an array of SaveResult objects. For each array entry that you passed in you get a SaveResult back. In your case, you passed an array of length 1, so saveResults[0].success is a boolean that signifies whether the create was succesful or not. If it was successful, saveResults[0].id is the ID of the generated record. If the create failed, saveResults[0].errors is an array of Error objects specifying what the problem was.

Take a look at http://www.sforce.com/us/docs/sforce70/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sforceAPI_WWHelp&file=sforce_API_calls_create_SaveResult.html#wp3131685

Todd Breiholz
PauloPaulo
That did it. Thanks for the quick reply.