1

I have a custom VF Primary Tab Component (Right Sidebar) in the console. That is on the Account layout, this loads to the right with a load of Opportunity information.

The issue I am having is I want to be able to click on the Opportunity name, when this is done it should open the Opportunity as a subtab of the Account... however this is not working -_-

This is my JS:

<script>
var oppId;

function openPrimaryTab(opp){
    oppId = opp;
    sforce.console.getPrimaryTabIds(showTabId);
}

var showTabId = function showTabId(result) {
    sforce.console.openSubtab(result.ids, '/' + oppId + '?isdtp=vw', false, 'salesforce', openSuccess, 'salesforceTab');
};

var openSuccess = function openSuccess(result) {
    if (result.success == true) {
        alert('Primary tab successfully opened');
    } else {
        alert('Primary tab cannot be opened');
    }
};
</script>

Link: <a href="#" onclick="openPrimaryTab('{!opp.Id}');return false">

Would anyone have any idea what I am doing wrong? I am stumped :/

1 Answer 1

1

The first parameter into openSubtab requires a single primary tab ID. The value result.ids which is returned in the callback from getPrimaryTabIds is an array of IDs. So your call to openSubtab fails because it's getting invalid input.

If you want a single ID of the primary tab your component is loaded in, you can use the method getEnclosingPrimaryTabId.

Sample code can be found here https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_opensubtab.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .