Today, there is no way to include a hyperlink inside of a formula field that will work inside of both native Salesforce as well as inside of a Salesforce Community or Console. The underlying for this is the way that Salesforce structures its base URLs inside of these three places:
- Native Salesforce: https://naX.salesforce.com
- Console: https://naX.salesforce.com/console/
- Community: https://mycompany.force.com/communityname/
You can write a relative URL using the following syntax, HYPERLINK("/"&Id, "Click Me") and the formula field will work fine inside of native Salesforce. If you click on the same formula field from inside of a Console, you are taken out of the Console back into the native Salesforce user interface since the relative URL does not grab /console/ from the base hyperlink when it creates the hyperlink. You want to navigate to https://naX.salesforce.com/console/15-digit-id but instead you are taken to https://naX.salesforce.com/15-digit-id The same is true for Communities; if you click on the same formula field from inside of a Community, the community name is dropped from the URL and you get an error message since you are taken to an invalid URL. You want to go to https://mycompany.force.com/communityname/15-digit-id but instead are taken to https://mycompany.force.com/15-digit-id, an invalid URL. If that formula field will only be used inside of that Community and no where else, you can make it work by hardcoding in the Community Name, using HYPERLINK("/communityname/"&Id, "Click Me") but it is less than ideal, especially if you are using a custom domain name in production.
Custom links and buttons support the use of URLFOR() and $Actions, which will dynamically determine the correct URL for users and allow hyperlinks to work inside of native Salesforce, inside of the Console and inside of a Community. However, formula fields do not support URLFOR() or $Actions, and there is no other way to dynamically determine the base URL. Please either allow URLFOR() inside of formula fields or another way of merging in the users's current base URL so that formula fields containing hyperlinks can work inside the native UI as well as Consoles and Communities!