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
ranirani 

Getting Newly Created Opportunity Id

Hi All,
I have created a new opportunity. After creating i have tried to retrive the new Opportunity Id by the following way, but is saying that it is undefined.
 
var saveResult = sforceClient.create([Opportunity]);

for (var i=-;i<saveResult.length;i++) {

    if (saveResult[i].success == true) {

       alert("Yay!! I created a record and the Id of the new record is: " + saveResult[i].Id);

    } else {

       alert("Rats!  There was a problem and I think the problem is: " + saveResult[i].errors[0].message);

    }

}

the saveResults[i].Id is not giving the newly created opportunity id. Can someone tell me how to get newly created opportunity id.

Any kind of help is appreciated.

Rani

gsickalgsickal
Id is case sensitive, your code should be saveResults[i].id, not saveResults[i].Id
ranirani
Thanks gsickal, it worked...Thanks a lot