[SalesForce] HYPERLINK function in a formula field returns different results

Background

I have a custom object Recipient__c with a Lookup relationship to Contact. Also it have another Master-Detail relation to another custom object SomeObject__c. The Name field for this object is defined as Auto Number (R-{0000000}).

By default when recipient records are displayed in a related list for any of its parents, users see "Recipient:Name" as one of its columns. By clicking on this field for any on the records in a list, users will be redirected to the Details page of the record.

The problem with this is that the "Recipient:Name" column displays values as "R-0000008", "R-0000002" etc., which is not very user-friendly, given that there will be many Recipient__c records assigned to a single parent record.

That is why I would like to find a way to have a field like "First & Last Name", which would be displayed on the related lists instead of "Recipient:Name", and it would also need to be a link. When users click on it they would be redirected to the relevant Recipient__c record.

What I did

I created a formula field on the Recipient__c object (HYPERLINK help article):

Field Label: Name

Field API Name: Name

HYPERLINK(Id, Contact.FirstName + " " + Contact.LastName)

Then I added this field to Related lists on the parent object.

Problem

When I go to the SomeObject__c detail page and click on the value in the Name column in the Recipients related list, I am getting the "URL No Longer Exists" error.

enter image description here

This is the actual URL https://<hidden>.my.salesforce.com/a021100000GblirAAB/a0311000007iFjp and it's wrong. It should be https://<hidden>.my.salesforce.com/a0311000007iFjp.

enter image description here

Interestingly when I go back to the SomeObject__c detail page and refresh the page, then the URL in the Name field becomes correct and I am redirected to the Recipient's detail page.

Does anybody know why this is happening?

Best Answer

Please add “/”+Id instead of “Id” in your formula field as it requires to be the relative URL.

Related Topic