4

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;
        }
    }
}
5
  • It used to work though in one of the last 2 releases I think Salesforce stopped supporting HTML in this cases. Trying to find the documentation... Commented Jun 26, 2014 at 23:23
  • 3
    Salesforce is becoming very particular about UI. Plus, it doesn't make sense from other perspectives, like API responses, especially SOAP. I think they're trying to avoid special use case scenarios, for performance reasons.
    – sfdcfox
    Commented Jun 26, 2014 at 23:27
  • 2
    Vote here success.salesforce.com/issues_view?id=a1p30000000T4PjAAK Commented Jun 26, 2014 at 23:34
  • They should make at least the delete page a bit more friendly then. I had to override the delete button just to have a nice message.
    – brovasi
    Commented Jun 26, 2014 at 23:34
  • I see the fix is now set for release in Winter 15
    – crmprogdev
    Commented Sep 13, 2014 at 15:09

2 Answers 2

1

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.

0
 item.addError('<span style="color: red;"><b>YOU CANNOT DELETE THIS EVENT</b></span>',false);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .