Answers for "database.update salesforce sr.getid null"

0

database.update salesforce sr.getid null

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) { //replaced by the following line
for (Integer i = 0; i < accountsList.size(); i++) {
    Database.SaveResult s = res[i];
    Account origRecord = accountsList[i];
    if (!s.isSuccess()) {
        system.debug(s.getId()); // I get null here
        system.debug(origRecord.Id); //This should be the Id you're looking for
     } 
}
Posted by: Guest on March-30-2021

Code answers related to "database.update salesforce sr.getid null"

Browse Popular Code Answers by Language