Salesforce Admin

Clickable Custom formula field (Relative vs Absolute)

Developers usually get strange requests from client to make some of the text clickable so that if a user clicks on that field in record it should redirect to detailed page of that record. We know that standard Name field already does similar task. However there will be a scenario where client uses Standard name field as auto number field and a custom field to save proper name and requests for a clickable link on the custom field and requests to make it clickable.

There are multiple ways in which we can perform this task. But in this blog we will see 2 ways using formula field.

One simple way that everyone follows is using a relative URL, where you can create a custom formula field and use relative URL with record Id.

For example “/005xx0000000XXX” is a relative URL and we can create a formula field by using this relative URL in a formula field.

A formula field for to create a clickable URL

You can use the below formula hyperlink to create clickable links.

HYPERLINK("/" & Id, Custom_Text_Field__c)

This formula works perfectly fine is used in any record or related record or as an even in reports.

The problem with this technique is it uses relative URL(“/<ID>”).  It works only when used on browser. This will not work when this field is sent as a report to user’s email. Outlook or Gmail will throw an exception if it gets any Relative URL, as it does not recognize salesforce if in its application. It is not always good to use relative URL.

We need to have a formula field which has Absolute URL. Meaning a URL which is complete like from BASE URL and ID of record.

Syntax for absolute URL:


Outlook or Gmail or any mailing service will treat this as an external URL and redirect it to browser.

We can active this absolute URL in formula field as shown below. Change the formula in the formula field to

HYPERLINK( LEFT($Api.Partner_Server_URL_340, FIND( '/services', $Api.Partner_Server_URL_340)) & Id , Custom_Text_Field__c )

$Api.Partner_Server_URL_340 will return a SOAP URL which also has a base URL in it. Something like this.


and we are taking the left part of “/service” which will be our Base URL.


followed by record ID.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s