+ Start a Discussion
Chad SaarChad Saar 

After creating an object, how do I get the object ID?

I am using the following line of code in the SDK to create a new Contact object. After creating the object how do I return the object Id?
 
SaveResult[] results = SfdcBinding.create(new sObject[] { contact });

 
Best Answer chosen by Chad Saar
William TranWilliam Tran
have you tried dot id notation like  results[0].id

or in a for loop:

for (SaveResult eachresult: results) {
 ........= eachresult.id;
}
  

All Answers

William TranWilliam Tran
have you tried dot id notation like  results[0].id

or in a for loop:

for (SaveResult eachresult: results) {
 ........= eachresult.id;
}
  
This was selected as the best answer
Chad SaarChad Saar
Thanks, that worked!