3

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:

mycompany.force.com/articles/article_id.

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?

1

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.

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

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">
    <html>
    <head>
    </head>
    <body>
        <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>
            </apex:column>
        </apex:dataTable>
    </body>
    </html>
</apex:page>
0

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

0
{!$Site.CurrentSiteUrl} 

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.

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.