+ Start a Discussion
Dave BerenatoDave Berenato 

Apex: OutputLink to open a new subtab in Lightning Console

I found some code in another post to make a Javascript button open in a new subtab inside the console:
<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
    <apex:includeScript value="/support/console/26.0/integration.js"/>
    <script type="text/javascript">
        window.onload = function(){

        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in

        var openSubtab = function openSubtab(result){
            var primaryTabId = result.id;
            sforce.console.setTabTitle('Add Rep Note');

I tried it for an apex:outputLink and it didn't work:
<apex:outputLink value="/{! record.id }" target="_blank"  id="theLink"><apex:outputField value="{! record.Name }"/>

The other question (https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000BTpTIAW) had code for the Javascript button but I don't know where to put that in the Visualforce Page.

var url = '/apex/Add_Rep_Notes?Id={!Account.Id}&isdtp=vw'; 

if (sforce.console.isInConsole()) { 
} else { 
I'm going to need this for several links on the page so I don't know how the "var url" would work.