function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mark YoungMark Young 

Multiple Custom Validation Errors - Apex Insert

Hi,

When performing a database insert, I'm only able to get back the first custom validation error.  Is there any way to get them all back?  Documentation says that all validation rules are evaluated.

I'm currently doing the following:
Code:
Contact c = new Contact();
Database.SaveResult result = Database.insert(c, false);

// Have multiple rules requiring fields to be set
System.debug('Num errors: ' + result.getErrors().size());  // Returns 1

 This should return all errors back, or else users are forced to do multiple round trips.

Any way to do this?

Thanks