You need to sign in to do that
Don't have an account?
GoForceGo
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');
}
}
trigger testAccountError on Account (after insert) {
for (Accout a: Trigger.New) {
a.addError('Error 1');
a.addError('Error 2');
}
}
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 ');
hth
Prabhan
Hi,
In Salesforce triggers, you can't directly display multiple error messages for a single record using addError. It's designed to add a single error message for a record. If you add multiple addError statements, only the last error message will be displayed.
To work around this limitation and display multiple error messages, you can accumulate the errors into a collection (e.g., a List) and then display them as a single error message. Here's how you can modify your trigger to display both errors:
I hope this will help you.
Thanks!