Each instance of a
Database.SaveResult corresponds to a result of a DML operation on a single record. According to the documentation, the method to get error details for a record actually returns an array of
Database.Errors instead of a single error.
- What are the instances when multiple errors occur?
- Inside each
Error, we can further find
getFields()why is this in plural again?
- Is there a proper way to construct a complete error message with all this information?
The 3rd question is because I have a pair of related objects and when the child record is updated, it flows to the parent record and if an error occurs in the parent update, I need to pass the details to the child record via a
.addError(). I have complex triggers on both objects and I use
optAllOrNone as false while inserting/updating the child record.