6

I have a custom object with a Long Text Area field to store a string that may be longer than 255 characters.

The contents of this string often includes text that looks like a hyperlink, but is not intended to be used as such.

E.g. somewhere in the value will appear a domain.com string:

Bacon ipsum dolor sit amet ground round exercitation google.com do laboris ham hock. Elit dolore aute consectetur, labore tenderloin anim eiusmod drumstick in.

Which Salesforce will render as: Salesforce Auto Hyperlink to Google.com in Bacon ipsum

How can I prevent Salesforce from automatically creating hyperlinks for these?

It seems to happen anywhere the field is used on a page layout or directly bound to in Visualforce.

I did find in Visualforce I could wrap the field in the controller and bind to a string version rather than directly to the field. This prevented the hyperlinks from being created.

E.g.

public class BaconWrapper {
    public Bacon__c bacon {get;set;}

    // Bind to this.
    public string BaconIpsum {
        get {
            return bacon.BaconIpsum__c;
        }
    }

    public BaconWrapper(Bacon__c cBacon) {
        this.bacon = cBacon;
    }
}
4
  • Were you using outputtext or outputfield? Apr 8, 2014 at 23:20
  • In Visualforce, among other things, I'm using <apex:column value="{!b.bacon.BaconIpsum__c}" id="theValue">. I guess I can deal with this field on a use-by-use basis to prevent the automatic hyperlinks. It doesn't directly address the standard page layouts. Apr 8, 2014 at 23:35
  • Can't you add a CSS class on that column and set text-decoration: none; property? Apr 8, 2014 at 23:41
  • I can handle the apex:column case by using the wrapper class to bind to a string rather than directly to the custom field. Ideally I'm looking for something I can do that will work everywhere for a string field that shouldn't contain hyperlinks. I suspect such a solution doesn't exist, but I'm happy to be proven wrong. Apr 8, 2014 at 23:55

1 Answer 1

2

Pending any better answers, I'm going to conclude that there isn't a built in way to avoid the automatic hyperlinking of Text Area fields. You'll need to manually wrap them in a class and expose the value via a string property, bind to an outputtext control, use a formula field, etc...

I've raised the idea: Make automatic hyper-linking on a Text Area field optional

You must log in to answer this question.

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