Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I add an email id as a hyperlink in a error message in a trigger?

share|improve this question
Where should this show up ? Standard pages or visualforce pages ? – Samuel De Rycke Jun 24 '14 at 7:19
up vote 3 down vote accepted

You shouldn't.

Triggers are executing when your data is manipulated, from whatever context (UI or API). It would be a bad design to assume which interface is the source of your trigger execution and create user specific messages at that point.

That beeing said, that doesn't always applies to salesforce, as for standard pages you don't have the luxery of running custom controllers, and validation rules kinda skip the same principle.

ALSO: mailto hyperlinks are not perceived as user friendly by most users and often only work well with device installed email clients, and not with web email clients (I believe).

share|improve this answer
You are right Samuel.Emaito: is not working.Though it is coming as hyperlink,but onclick it is not going to the web mail there any work around for this? – SalesforceAspiration Jun 24 '14 at 7:41

Use addError(String, Boolean) with false to the second parameter so that it'll not escape HTML markups in your string message.

obj.addError('ERROR:<a href=\'your_link\'>More details</a>', false);

Found this similar post on success community.

share|improve this answer
Thanks highfive.It id working.But onclick on the hyperlink it is not going to the email page. – SalesforceAspiration Jun 24 '14 at 7:36
The answer is just to explain how we can apply HTML formatting with the addError method. As @SamuelDeRycke has mentioned mailto hyperlinks are not going to be work well always without email clients – highfive Jun 24 '14 at 8:01
I think this should be the accepted answer to the question tbh. – Samuel De Rycke Jun 24 '14 at 16:35

You can use apex:pageMessage tag with escape="false" then use try catch to catch the error from trigger and format the error putting html tags for email id. Now apex page message will display hyper link

share|improve this answer
It is a standard page. – SalesforceAspiration Jun 24 '14 at 7:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.