List <Account> conList = new List <Account> { new Account(Name = 'Test Account1', Phone = '8888888888', Industry = 'Agriculture'), new Account(Name = 'Test Account2', Phone = '7777777777', Industry = 'Banking'), new Account(Name = 'Test Account3', Phone = '9999999999', Industry = 'Finance'), new Account() }; Database.SaveResult[] srList = Database.insert(conList, false); for (Database.SaveResult sr : srList) { if (sr.isSuccess() ) { //Develop code for successfully inserted Accounts System.debug('Successfully inserted Account ' + sr.getId()); } else { for (Database.Error err : sr.getErrors()) { //Develop code for failed Accounts System.debug(err.getStatusCode() + ' : ' + err.getMessage() + ' : ' + err.getFields()); } } }
Partial Apex DML Example in Salesforce
Biswajeet
November 12, 2017 No Comments on Partial Apex DML Example in Salesforce