The value returned from sforce.console.getEnclosingTabId seems to always be a subtab value. Even though it is not opened as a SubTab.
I've tried to compare against the sforce.console.getEnclosingPrimaryTabId and other functions but it doesn't look right.
Is there something that I'm missing?
This is what I was trying to do.
sforce.console.getEnclosingTabId( function (enclosingTabInfo) {
var enclosingTabId = enclosingTabInfo.id;
sforce.console.getEnclosingPrimaryTabId( function (primaryTabInfo) {
if (enclosingTabId === primaryTabInfo.id) {
console.log("Is primary Tab");
} else { console.log("Is SubTab");
});
})
I think I know what is happening. All Tabs have a subtab (by default even if it doesn't look like it). So if you have one primary Tab and you do a getSubtabIds() call, it will return a single subtab id still. And that is what is being returned by the getEnclosingTabId() call. So I guess to check if it is a subtab I'll have to check if the primary Tab has two subtabs or not.
Best Answer
I realize this is 2 years late, but in hopes this could help someone else, here's how to determine whether you are in a subtab or primary tab.
Example use: