In an Apex class method, I want to add several Accounts to a List. After a successful execution of the insert, can I access Ids?
Example:
List<Account> accounts = new List<Account>();
Account newAccount = new Account();
newAccount.Name = 'Acme, Inc.';
accounts.Add(newAccount);
insert accounts;
for (Account thisAccount: accounts) {
System.debug(thisAccount.Id);
}
Will thisAccount.Id have a value or must I execute a new SOQL statement?
Per this documentation under Inserting Related Records, it looks like it should contain the newly-assigned Salesforce Id.