1

I need to access a constant that holds a URL via an email template(= visual-force page) without using a controller. Because if I use a controller I will need to write test code and also maintain more code.

I have just seen that there are some out-of-the-box features that can be used directly in visual-force pages. For instance, $Api.Partner_Server_URL__xxx, that will return an API endpoint.

I would like to achieve the same, I mean to retrieve a custom URL in the same manner. Something like $Company.Url = www.company.com.

Is this possible?

6

A mechanism you could use is a hierarchical custom setting. Values can be accessed directly in Visualforce using $Setup.

Here is the example from the docs:

<apex:page>
    <apex:inputField value="{!usr.Workstation_Height__c}"/>
    <apex:outputPanel id="helpWorkstationHeight" 
        rendered="{!$Setup.App_Prefs__c.Show_Help_Content__c}">
        Enter the height for your workstation in inches, measured from the 
        floor to top of the work surface.
    </apex:outputPanel>
    ...
</apex:page>
1
  • This is a nice solution; however, only profiles that have activated the security feature "Customize Application" can access the custom settings. Activating this feature will lead to a security threat. I which Salesforce would provide a better solution for this cases. Sep 14 '17 at 13:22

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.