1) In my opportunityLineitemtrigger, I have a method which updates the opportunity.
system.debug('######');
database.saveresult [] rst = database.update(oppList,true);
system.debug('######'+rst);
While updating the opportunity, it calls the before update trigger event of opportunity. In that before update trigger method, I have used an add error method to throw an error message for some of the records which met the criteria
for(Opportunity opp : newList){
if(opp.RecordTypeId != SEUtility.getRecordTypeId(SEUtility.OPP_RECTYPE))
{ opp.addError(Label.Record_type_not_allowed_to_change);
}
}
Once the before update triggers fire with adderror , I dont get anything in database.saveresult in the above code , the debug line system.debug('######'+rst); doesn't gets executed , on checking the logs I see the adderror exception.
Is this is as per salesforce guidelines, since I know when we used database.saveresult it will show the records which got failed and which got succeeded. If for adderror some records failed why cant I get that details in the saveresults.
2) Secondly I see a big error message in RED as
Review all error messages below to correct your data. Apex trigger OpportunityLineItem caused an unexpected exception, contact your administrator: OpportunityLineItem: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0061p0000iuy7AAQ; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Fill the values as per the standards: []: Class.OpportunityLineItemTriggerHandler.updatesalesvalue: line 95, column 1
If I am using adderror , it should have been the single line custom error message which i had defined but why so many details shown on UI ?