2

I have this field of type URL on the Accounts page and need to represent the extremely long URL value with common plain text. To illustrate, instead of this:

enter image description here

I need to have something like 'BH Website' as the field value AND hyperlink it to the desired webpage like it works currently.

How can I achieve this?

2 Answers 2

3

You can do this with a couple of extra fields.

First create a text field with the maximum length you desire called URL_Name__c or similar.

Then create a new formula field that returns a text value. Inside that the formula uses the HYPERLINK function to combine the two other fields into a shorter link.

HYPERLINK(Website, IF(ISBLANK(URL_Name__c), Website, URL_Name__c), 'blank')

Note that with this basic formula, if the Website field does not contain http:// then the link will try to link to an internal location, so that should always be specified. If you want to make the formula more tolerant of this, then you can also check for the presence of "http" at the start of the URL:

HYPERLINK(
  IF(LEFT(Website, 4) == 'http', Website, 'http://' + Website),
  IF(ISBLANK(URL_Name__c), Website, URL_Name__c),
  'blank'
)
3
  • Thanks Lacey, this is a complete solution. Works in any case.
    – Rosh
    Sep 7, 2013 at 6:46
  • @laceysnr how do I do this in Apex? Is it possible?
    – user988
    Nov 26, 2013 at 19:38
  • In apex you'd just build up a URL intro a String variable, then use that as the URL for a link in the page: href="{!theLink}"
    – Matt Lacey
    Nov 26, 2013 at 23:16
1

What LaceySnr has written up will definitely work, and is probably your best option if you have a lot of pre-existing data. If you don't have pre-existing data, you may find it's simpler just to add a rich text field. Rich text fields allow for limited HTML, but one of the things they allow is linked text.

1
  • I highlighted the contents of this field and hyperlinked it to the concerned URL like you directed. Thanks a lot. This is the simplest solution.
    – Rosh
    Sep 7, 2013 at 6:45

You must log in to answer this question.

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