I have a data model that has multiple levels of master-detail relationships. While a hyperlink to the immediate parent object is easily available, adding a link to a more distant ancestor, the Parent__c link on the GrandChild__c object in this diagram, is more awkward:
If you make Parent__c a “Lookup Relationship” field then you must also add logic such as a trigger to populate the Id value correctly whatever changes are made. This can be awkward to code and requires quite a lot of test cases.
If you make Parent__c a “Formula” field, then at first sight it is not possible to have a hyperlink presented in the user interface because the “Formula Return Type” options do not include such an option.
But a colleague has just passed a solution on to me that he found in part in the post Lookup Formula Fields. Using a “Formula Return Type” of “Text” this formula can be used:
HYPERLINK(Child__r.Parent__r.Id , Child__r.Parent__r.Name, "_self")
resulting in a hyperlink to the Parent object that opens within the existing sidebar and header when clicked and most importantly requires no additional logic to keep the values updated.