function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eric VitucciEric Vitucci 

From support console open in a new tab.

I have a visual force page in our support console that when yo click on the name of the account it opens the account page. I would like it to open a new tab on the console instead of going to the account and leaving the console. I can't seem to figure out how to do this. Here is my code.

<apex:page showHeader="false" standardStylesheets="false" standardController="Case">

<style>
p.small {
    line-height: 0.5;
}

</style>

            <p> <font face = "Arial" size = "3"><b><a style="text-decoration:none" href="#" onclick="window.top.location='/{!Case.AccountId}';">{!Case.Account.name}</a></b></font></p>
            <p class="small"> <font face = "Arial" size = "2"> <b>Support Level:&nbsp;</b> <apex:outputField value="{!case.Support_Level__c}"/> </font></p>
            <p class="small"> <font face = "Arial" size = "2">  <b>Customer Tier:&nbsp;</b> <apex:outputField value="{!case.Customer_Tier__c}"/> </font></p>
            <p class="small"> <font face = "Arial" size = "2">  <b>ASA Expiry Date:&nbsp;</b> <apex:outputField value="{!case.ASA_SUB_Next_Renewal_Date__c}"/> </font></p>

</apex:page>
 
jigarshahjigarshah
Eric,

You could leverage the openPrimaryTab() (https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_openprimarytab.htm) and openSubTab() (https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_opensubtab.htm) methods provided by sforce Javascript library, to open the Account record as a separate Console tab versus a new window.

Using the openPrimaryTab(), your existing code would need the anchor tag to be modified as follows.
<!-- Add reference to the below library -->
<apex:includeScript value="/support/console/40.0/integration.js"/>

<a style="text-decoration:none" href="#" onclick=openConsoleTab(); return false;;">{!Case.Account.name}</a>

    <script type="text/javascript">
	
        function openConsoleTab() {
		    //Open a new primary tab for the associated Parent Account on Case
            sforce.console.openPrimaryTab(
				null, 
				'/{!Case.AccountId}', 
				true, 
                '{!Case.Account.name}', 
				openSuccess, 
				parentAccountTab);
        }
        
        var openSuccess = function openSuccess(result) {
            //Report whether opening the new tab was successful
            if (result.success == true) {
                console.log('Tab open success');
            } else {
                console.log('Tab open failed');
            }
        };
        
  </script>
Please DO NOT forget to mark this thread as SOLVED if this answer helps resolve your issue.
Pavit SiddhuPavit Siddhu

Hello

pass the target attribute set the value that suits you

<a style="text-decoration:none" href="#" onclick="window.top.location='/{!Case.AccountId}';" target="-parent">

Eric VitucciEric Vitucci
Hi jigarshah, I haven't got your code to work yet, I think I have an issue somewhere. pavit kumar I tried your code but it still opened in a different window not in a tab in the console. Thank you both for responding to my questions. 
jigarshahjigarshah
Eric, please share the error message or details aof the issue along with your codebase. I might be able to help you troubleshoot the issue.
Eric VitucciEric Vitucci
Hi Jigarshah,

When I click on the account name nothing happens, no code error nothing. If I open in a new tab it just show the same tab and doesn't open the account record.