0

How to access custom setting url field in apex.In my class i have a link in success message "Create Record". when user click the link it will diplay the site page.My problem is how to access the url field in herf link.

Now i have use below code in my class

successMsg ='Please click the link to create more records -a href="http://test-site.cs18.force.com/Account" <font size="3px"><b>Create Record</b></font></a>' ;

Now i have trying the below code but im not getting the solution.

successMsg ='Please click the link to create more records -a href="{!$Setup.AccountURL__c.Url__c}" <font size="3px"><b>Create Cases</b></font></a>' ;

Please guide me.

0

To have the HTML in an ApexPages.Message rendered as HTML the default escaping must be turned off in the Visualforce:

<apex:pageMessages escape="false"/>

and values of hierarchy custom settings can be accessed in Apex code like this:

String s = 'Message with <a href="' + AccountURL__c.getInstance().Url__c + '">link</a>';
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.INFO, s);
2
  • thanks for the reply im using this code but im getting visualforce error.So i have check the debug log, string value its shows null. – user10286 Jul 26 '14 at 5:33
  • Have clicked the "Manage" button for the setting and "New" and set a value for the Url field and clicked "Save"? – Keith C Jul 26 '14 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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