+ Start a Discussion
Manohar kumarManohar kumar 

Hyperlink in ApexPages.AddMessage

Hi All,

i have a custom button on opportunity to create case.Our requirement is that one opportunity should be associated with one case.I made one url field on opportunity to store case url.Now the problem i am facing is how do i put hyperlink in my Error message so that user can go to the associated case if any case is already linked with opportunity.

I am using one page in the middle.This page calls the New url for created case.And updating the Field of the opportunity.I am using apex pageMessages tag on the page.Its working but i am not able to show hyperlink to the related case.

if(o1[0].Related_Case__c == null) {
				o1[0].Related_Case__c = hostVal+'/'+c1.id;
        		system.debug('##o1'+o1);
        		update o1;
        		PageReference p1 = new PageReference('/'+c1.id);
            	system.debug('###p1'+p1);
            	return p1;
			}
			else{
				
			String link = '<a href="https://cs87.salesforce.com/'+o1[0].Related_Case__c+'></a>';
 				ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'record already there'+ link));
				
				return null;
				
			}
 

Any help will be appreciated.

Thanks,

Manohar

Apoorv Saxena 4Apoorv Saxena 4
Hi Manohar,


Try setting escape attribute in <apex:pageMessages> to false in your VF page.
 
<apex:pageMessages escape="false"/>


Please mark this question as solved if this helps so that other can view it as a proper solution.

Thanks,
Apoorv