0

How to define id:String in sforce.console.openPrimaryTab instead of null in salesforce? Here is the code that using, and i am getting openPrimaryTab: Invalid ID: error. any suggestions?

function OpenTab() {
    sforce.console.openPrimaryTab('{!contact.ID}', '/apex/contactPage?scontrolCaching=1&id={!contact.ID}', true, 'contact');
}
0

You are passing contact record Id instead of the existing primary tab Id, which you want to override.

If you don't want to override any existing primary tab and simply open a new primary tab, it should be as :

sforce.console.openPrimaryTab(null,'/apex/contactPage?scontrolCaching=1&id={!contact.ID}', true, 'contact');

Update:

If you want to override an existing primary tab Id, use one of the below methods to get the existing Primary Tab Id:

1) sforce.console.getPrimaryTabIds((optional) callback:Function)

If you have more than one primary tab opened, loop through the Ids returned by the above method by passing to the below method :

getPageInfo(tabId)

This method will give you back the object Id and some other info, refer to the doc for more details.

2) sforce.console.getEnclosingPrimaryTabId((optional)callback:function)

If you want to refresh the current primary tab, use the above method.

  • i want to set the ID not null, based on that i want to close the TABS to maintain only one ext tab open active at a time. – KrForce Aug 20 '15 at 18:29
  • then use the method sforce.console.getEnclosingPrimaryTabId() to get the primary tab Id and pass that as the first argument. – javanoob Aug 20 '15 at 18:31
  • getEnclosingPrimaryTabId will give the current tab ID, the issue that i'm trying to resolve is keeping only one External tab/CanvasTAB(Ext tab im brining legacy application through the canvas VF page). if i want to override the currently opened EXt primary tab i need the EXT tabID to close it and open the new tab. question is how to get the currently opened ext tab ID? – KrForce Aug 20 '15 at 19:06
  • I think you can override the tabs which are opened by the sforce.console API..If it was external tab, you cannot override. One thing you can do is close that external tab and open new Primary tab – javanoob Aug 20 '15 at 19:09
  • Even to close TAB i need to get the ID of currently opened TAB, any suggestions to get the ID dynamically? This is what im doing now to close the TABS..hard coded TAB id's i want to get the ID dynamically.function CloseProAdvTab() { alert('CloseProAdvTab called'); var tabId1 = 'scc-st-1'; var tabId2 = 'scc-st-2'; var tabId3 = 'scc-st-3'; sforce.console.closeTab(tabId1); sforce.console.closeTab(tabId2); sforce.console.closeTab(tabId3); } – KrForce Aug 20 '15 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.