[SalesForce] Opening case (hyperlink) in primary tab

I have a page on console where case number is shown as hyperlink. When it is clicked it should open in the same tab which is primary tab. I created formula field using Hyperlink function.It is opening the case in new tab. How can I show the case in the same tab?

HYPERLINK('https://dev2.salesforce.com/console?tsid=02u50000000VVyQ#%2F'+ id,Casenumber)

I tried using _self,_top,_parent as third parameter, But they did not give me the result as I desired

Best Answer

You need to inject javacript to open the record in same tab.

Here is an example

HYPERLINK("javascript:if(typeof(srcUp)=='function') {srcSelf('/" & Id & "');} "+ 
" else {window.location.href='/" & Id & "'}" 
,Casenumber 
, "_self" 
)

For more information, refer my blog. Different ways of navigation

Update

As per comment, take this approach, for create a Custom Button or Link executing JavaScript

{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/28.0/integration.js")} 
var url = '/apex/VisualforcePage'; 
if (sforce.console.isInConsole()) { 
navigateToUrl(url + '?inline=1'); 
} else { 
window.open(url,'_self'); 
}