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
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!