I created a Custom Object with a Rich Text Field. The custom object is accessible internally to Salesforce as well as externally in our Customer Portal via a VisualForce page.

In the text field for this object, I am displaying a link to a URL. Currently it is hardcoded to this:


How would I make it so that the link in the customer portal stays the same, but if I access the link internally, it becomes na4.salesforce.com/articles/article_id?

4 Answers 4


Create 2 text fields :

  • External_URL__c = mycompany.force.com/articles/
  • Internal_URL__c = na4.salesforce.com/articles/

Create another 2 fields, formula fields, that will concatenate the correct URL, with article_id.

Your Formula field will look like this:

  • Display_External__c = External_URL_c & Article_id
  • Display_Internal__c = Internal_URL_c & Article_id

You display the correct field to your users and portal users.

  • Would I be able to access those fields from my Rich Text Field? if so, how?
    – Di Zou
    Commented Nov 5, 2012 at 20:56

I made a field in my custom object called Knowledge Article. Then this is what I did in my VF Page:

<apex:page id="patchpage" showHeader="false" sidebar="false" standardController="MyObj__c" recordSetVar="obj">
        <apex:dataTable value="{!obj}" var="o" rows="50" id="table">
            <apex:column >
                <a target="_blank" href="/articles/{!o.Knowledge_Article__c}">{!o.Title__c}</a><br></br>

Generally speaking looks like you just need to display a relative URL like /articles/article_id and you'd be fine in both situations? Browser should display it properly.

Looks like some kind of Apex trigger would be needed to modify the content of RTF field on every insert & update.

Quick search led me to https://stackoverflow.com/questions/2850575/what-is-the-rtf-syntax-for-a-hyperlink - syntax looks horrible but in theory you'd just have to cut out the domain names from the link during saving and it should work? How well Salesforce conforms to RTF spec is probably totally different matter...


Returns the value of the site URL for the current request (for example, http://myco.com/ or https://myco.force.com/prefix/).

LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))

Will give you the salesforce base URL for use by Salesforce users

If you store the URL as relative URL in a custom field (works inside Salesforce) and when rendering via VF for external users, use String Manipulation to append the external URL prefix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .