I'm currently using a formula field with a HYPERLINK function in the Account object to show the value of Custom_Object_Field__c from a custom object which also redirects the user to the custom object record page when clicked.

Here's the formula expression so far that is working when the user is viewing from the record page with a URL https://mysite.sandbox.lightning.force.com/lightning/r/Account/000000000000000/view (take note of the '/r/'):

    IF( Custom_Object__r.Custom_Object_Field__c= "", 
    hyperlink("../../Custom_Object__c/" + Custom_Object__c.Id + "/view", Custom_Object__r.Id.Custom_Object_Field__c,"_self")

However, when the user views from the list view of the Custom Object with a URL https://mysite.sandbox.lightning.force.com/lightning/o/Account/home (take note of the 'o'), it doesn't work since I don't have the condition to append the '/o/' when viewing from the object list view.

How should I reference and differentiate the URL in the formula expression so I can write a CASE() function?

I already tried fetching the base URL but the /lightning/o/ or /lightning/r/ are not being included.


2 Answers 2


You can use a relative url to just the record id like this which should work in all contexts. HYPERLINK("/" + Custom_Object__c.Id, "label", "_self")


I implemented the following formula expression to come up with the correct functionality. I added the base URL as mentioned here.

hyperlink(LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260)) + "lightning/r/Custom_Object__c/" + Custom_Object__r.Id + "/view", Custom_Object__c.Custom_Object_Field__c,"_self")

It's now working. Thanks!

You must log in to answer this question.

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