I have after update trigger on contact.
I am trying to write a friendly error to screen whenever x is happening.(in apex code)
I followed this explanation:
Difference between the multiple messaging options in Visualforce?
and this one:
https://albasfdc.com/2017/04/17/demystifying-adderror/
Are they still relvant?
When i Use just adderror from trigger context, nothing breaks and no error is thrown to screen.(maybe i should use vf Page? couldn't make it work... what should be the standrdcontroller, anyway to rerender after saving contact record) When i do something like:
trigger triggerTry on contact(after update){
list<string>contactIds = new list<string>();
for(Contact contact: trigger.new){
contactIds.add(contact.id);
}
list<contact> contacts = [select id from contact where id in : contactIds];
contacts[0].adderror('error');
}
I get something like:
caused by: System.Exception: SObject row does not allow errors".
Any simple example for this situation?(Raising friendly user error from trigger context)