Is it possible to add a clickable url using ApexPages.addMessage? I am using ApexPages.addMessage to show an information alert but I would like to include a dynamically generated URL within the ApexPages.addMessage. The URL would be to a record within the same org.

Something like:

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Potential duplicate'+<a href="/o.Id">Click Me</a>))

I guess if this isn't possible then I will need to add my own pageBlockTable which only renders when it has a value.

1 Answer 1


That should be possible. You would want to change it to be more like this though:

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Potential duplicate <a href="' + o.Id +'">Click Me</a>'));

The markup will just be part of the String.

You also need to render the apex:pageMessage with escape="false" for the HTML to be rendered properly.


You must log in to answer this question.

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