Notes
In Salesforce Apex, Database.SaveResult[]
is an array that holds the results of a DML operation, such as inserting, updating, or deleting records. Each element in the array corresponds to a record involved in the operation, and you can use it to check whether the operation was successful for each record.
Here's a simple example using Database.SaveResult[]
with an insert operation:
Account newAccount = new Account(Name='New Account', Industry='Technology');
Account nullAccount = new Account();
List<Account> accountList = new List<Account>{newAccount, nullAccount};
Database.SaveResult[] insertResults = Database.insert(accountList, false);
for (Database.SaveResult sr : insertResults) {
if (sr.isSuccess()) {
System.debug('Record successfully inserted. ID: ' + sr.getId());
} else {
for (Database.Error error : sr.getErrors()) {
System.debug('Error message: ' + error.getMessage());
}
}
}
Output:
Record successfully inserted. ID: 001Dn00000s7mnOIAQ
Error message: Required fields are missing: [Name]
Video
Video does not exists.