This post will explain how to open the detail page in a sub-tab after clicking on the hyperlink.
Recently I faced one problem where I need to open the details page of a record in sub-tab inside Service Console by clicking on the hyperlink.
Normally if you have any lookup field in service console layout, the field will appear as hyperlink and clicking on the link will open the detail record in sub-tab.
But in my case, I need to make a custom formula field with return type as Hyperlink. Making a formula field as hyperlink is very easy and if you add the field in the page layout, that field will appear as hyperlink. But the problem comes when you click on the link. Clicking on the link will open the page in another browser tab, which is a little odd. User may feel that they are thrown out of the service cloud console by clicking on a record.
So to improve this user experience, we need to open the detail page in the sub-tab of service console. Below is the formula field which display “Product Name” in the page layout as hyperlink and clicking on that link will open the product detail page in sub-tab by passing the product id.

if(typeof(srcUp)==’function’) {
srcUp(‘/” & Product2.Id & “?isdtp=vw’);
}”+ ” else {
window.location.href=’/” & Id & “?isdtp=vw’
Product2.My_Product_Name__c, “_self”)

Sharing the information here so that it can help others. Please let me know if you have any better approach to achieve the same.