Here I'm just written code for finding a duplicate record and displaying link through the hyperlink but it's working fine in the classic but lighting it showing directly code. Please just check images hyperlinks that displaying in classic and lightning. Why ??

Please find Image for reference

enter image description here

Here it is not showing hyperlink properly


Trigger.new[0].addError('ENTERED PARTNUMBER ALREADY EXISTS FOR THIS SUPPLIER PLEASE CHECK<a target="_blank" href=\'https://my.salesforce.com/'+stc.Id+'\'>VINOD</a>', false);

1 Answer 1


This is a limitation in Lightning and mobile app.

addError(errorMsg, escape)

Marks a trigger record with a custom error message, specifies if the error message should be escaped, and prevents any DML operation from occurring.


  1. errorMsg :- Type: String The error message to mark the record with.
  2. escape:-Type: Boolean Indicates whether any HTML markup in the custom error message should be escaped (true) or not (false). This parameter is ignored in Lightning Experience and the Salesforce app and the HTML is always escaped. The escape parameter only applies in Salesforce Classic.


The escaped characters are: \n, <, >, &, ", \, \u2028, \u2029, and \u00a9. As a result, HTML markup is not rendered; instead, it is displayed as text in the Salesforce user interface.


Be cautious if you specify false for the escape argument. Unescaped strings displayed in the Salesforce user interface can represent a vulnerability in the system because these strings might contain harmful code. If you want to include HTML markup in the error message, call this method with a false escape argument. Make sure that you escape any dynamic content, such as input field values. Otherwise, specify true for the escape argument or call addError(String errorMsg) instead.

Reference:- SObject Class

  • I got it what you're saying, how can I do this now in lighting ??? Do you have any idea ?
    – VINOD
    Dec 2, 2019 at 10:54

You must log in to answer this question.

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