Sunday 16 July 2017

Not rendering Clickable Link on Visualforce Page in apex:pageMessages

Hi Folks,

I was trying to cover a scenario I need to show a clickable link on visualforce page on some error condition with a navigating back to original record. 

I know we have in built standard tag i.e 

apex:pageMessages


Lets say you want to show a clickable message that needs to be redirected to some other link . This navigation can be done within or outside salesforce. So, generally we use the below line to show the clickable link. 

           String orderId = System.URL.getSalesforceBaseUrl().toExternalForm();
            String err = '<b><a href="' + orderId +'/'+OrderId+ '">Click Here to Continue  here</a>.';
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,err));

But some how it was showing me on the page as like this "'<b><a href="' + orderId +'/'+OrderId+ '">Click Here to Continue here"

But then I checked that there is an attribute i.e Escape

A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. Be aware that setting this value to "false" may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner.

If I make Esacape = false then it renders as link. 

Thanks
Ankush


Happy Coding 😉




oAuth Use Case -  Headless API Explained in the Easiest way Wondering why? and When we use the Headless API flow Use case example: Imagine a...