Find your content:

Search form

You are here

How do I get a custom object to display a relative URL?


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

Attribution to: Di Zou

Possible Suggestion/Solution #1

Create 2 text fields :

  • External_URL__c =
  • Internal_URL__c =

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.

Attribution to: Saariko

Possible Suggestion/Solution #2


Returns the value of the site URL for the current request (for example, or

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.

Attribution to: techtrekker

Possible Suggestion/Solution #3

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 - 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...

Attribution to: eyescream

Possible Suggestion/Solution #4

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>

Attribution to: Di Zou
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content