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

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:
// 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);


Can salesforce return the id?


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

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