+ Start a Discussion

adding error messages to multiple records


If i need to add errors to multiple objects that caused the eror.

I am executing triggers and i add apex.add message

but i want to add the message to the multiple objects that created the error

how cna i achieve ot ?

Best Answer chosen by Sandrine
Lalit Mistry 21Lalit Mistry 21
Hi Sandrine,
Assuming you want to have trigger on contact object, you can a trigger like below
trigger ContactTrigger on Contact(before insert)
	for(Contact cnt : Trigger.new){
		if(/*check for error condition*/) {
			cnt.addError('Error message');

Similarly you can work it out for an object of your interest.