[SalesForce] openPrimaryTab() not opening more than one tab with a tabLabel – Console

I am unable to open multiple tabs with a tabLabel but CAN open multiple tabs without a tabLabel. I can't find any documentation on why this would be happening or any further explanations on the (optional)tabLabel:String section of the openPrimaryTab() function. Any insight would be appreciated.

I have tried binding in a value, hard typing in a value, putting in a datetime and as far as I can tell, if there is any value in the tabLabel, then multiple tabs will not pop.

    sforce.console.openPrimaryTab(null, '/' + id, true, 
   '{!title}', openSuccess, 'Case On Case');

When I remove the tabLabel, I am able to get multiple tabs to pop.

sforce.console.openPrimaryTab(null, '/' + id, true, openSuccess, 'Case On Case');

Any ideas?

Best Answer

In this case, you need to specify undefined rather than defined as null in the first argument of

sforce.console.openPrimaryTab(***id:String***, url:URL, active:Boolean, (optional)tabLabel:String, (optional)callback:Function, (optional)name)

So, it will be as follows:

sforce.console.openPrimaryTab(undefined,"/"+id, true, '{!title}');

In the below picture you can see that clicking each record, it is opening in separate Primary tab with title.

Open Primary Tab

Updating answer based on comments

If the ID corresponds to an existing primary tab, the existing tab is redirected to the given URL because the Salesforce console prevents duplicate tabs.

Now, if you do not specify the Id then it should be undefined as there is difference between null and undefined

Related Topic