[SalesForce] How to open a Visualforce page using formula (Hyperlink) field dynamically from console or standard SF

I have a visualforce page. I need to open that page in Service Cloud Console sub-tab when user is within Service Cloud Console with some required parameters and if user is not within console then the page should be open in the SF Classic.

Thanks in Advance!!

Best Answer

Thanks All!!

Below formula is working for me

HYPERLINK("javascript:if(typeof(srcUp)=='function'){
     srcUp('/apex/SL_MyPage?p=" & Custom__r.Id & "&d=" & Custom__c&"');}
"+" else {window.location.href='/apex/SL_MyPage?p=" & Custom__r.Id & "&d=" & Custom__c&"'}", 
"Formula Label"),"_self")