How to show a hyperlink in error message in lightning?

I wrote a trigger a trigger on Lead object for a validation.
If validation is failed, I’m showing a link in error.

l.addError(‘A Lead is already exist with the given email id. Refer : ‘+link,false);
It is working fine in classic, but not working in Lightning.
enter image description here

Please help me to achieve this.

Answer

The feature is not yet available in Lightning experience.
the documentation says :
addError(errorMsg, escape)
Marks a trigger record with a custom error message, specifies whether or not the error message should be escaped, and prevents any DML operation from occurring.
Signature
public Void addError(String errorMsg, Boolean escape)

Parameters
errorMsg
Type: String
The error message to mark the record with.

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.

reference : https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_sobject.htm

Attribution
Source : Link , Question Author : manoj , Answer Author : Kris Goncalves

Leave a Comment