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
Sandy Cook 1Sandy Cook 1 

getEnclosingPrimaryTabId: Cannot get workspace from frameId

Hi,

I've got a Custom Visualforce page which is attempting to open a tab from a link.

I'm using the standard exmaple code from https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_opensubtab.htm

However there are zero tabIDs coming back from the page so opening a new tab fails. Code looks like

<apex:column ><A HREF="#" onClick="testOpenSubtab();return false">Click here to open a new subtab</A> </apex:column>


<apex:includeScript value="/support/console/42.0/integration.js"/>
    <script type="text/javascript">
        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            console.log(sforce.console.getFocusedPrimaryTabId(showTabId));
            if(sforce.console.isInConsole()){
                    sforce.console.getEnclosingPrimaryTabId(openSubtab);
            } else {
                   console.log('we are not in console');
                }

        }
        var showTabId = function showTabId(result) {

            //Display the primary tab IDs
            
            console.log('1');    
            console.log(result.ids);
            console.log('2'); 

            };

        
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            console.log("primaryid" + primaryTabId);
            console.log(result);
            sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 
                'salesforce', null, openSuccess, 'salesforceSubtab');
        };
        
        var openSuccess = function openSuccess(result) {
            //Report whether we succeeded in opening the subtab
            console.log(result);
            if (result.success == true) {
                alert('subtab successfully opened');
            } else {
                alert('subtab cannot be opened');
            }
        };
    </script>


The resulting console output is.

User-added image
Come someone point out what I'm missing / doing wrong here? 
Many thanks.

Best Answer chosen by Sandy Cook 1
Sandy Cook 1Sandy Cook 1

I'll answer that someway down the road.

The ability of the relationship seems to work quite well here. The example shows the link from a Task to the associated Case.

<apex:column width="120" value="{!t.WhatId}"/>
Creating something like this

User-added image