I believe it's a known issue, but I was wondering if there is still no work around this.
In my trigger, sobject.addError always escape my html tags even if I set escape to false.
This is really annoying. I would love to make the error message a bit more friendly when a user try to delete an event.
trigger EventTrigger on Event (before delete) {
for (Event item : Trigger.old){
if(item.EndDateTime < System.now() || item.ActivityDate < System.now()){
item.addError('<span color="red"><b>YOU CANNOT DELETE THIS EVENT</b></span>',false);
return;
}
}
}
Best Answer
This is fixed now. You can set escape to false for delete triggers now. But they applied a condition here that this would only work in classic, not in lightning, not in salesforce1. Other than classic String would always be escaped.
I wrote an answer here which you can read as well for the same.