I'm trying to update an account list and I need to get the Ids when the update fails.
I use the getId()
method but for accounts which fail I get null
.
It's an update so my account already has an Id.
Is it normal ? If it is, how can I get the Ids list of non-updated accounts ?
Here is my code :
List<Account> accountsList = [select Id from Account];
for(Account a : accountsList) {
a.Name = 'Test',
}
List<Database.SaveResult> res = Database.update(accountsList, false);
for (Database.SaveResult s : res) {
if (!s.isSuccess()) {
system.debug(s.getId()); // I get null here
}
}