+ Start a Discussion

Using addError to add multiple Errors.

The following code only shows Error 2. How can one modify it to show both errors (short of accumulating all errors and showing as one large string).

trigger testAccountError on Account (after insert) {

        for (Accout a: Trigger.New) {
            a.addError('Error 1');
            a.addError('Error 2');

It does that because it is addError, not addErrors. ;)

If you want to show new line in the message, u might try '</br>' or  '\n' in the addError(), something like this:
string br = '</br>';
a.addError('Error 1'+br+'Error 2 ');