1

I am attempting to create a custom highlight panel. What I ultimately need to do is on the focus of a subtab, I need an event to fire and send information to the highlight panel. The highlight panel is for the primary tab (Account), and the event needs to fire from the subtab (Opportunity). The reason I need to do it like this is because we pull in information via an outside API (which is displayed on the subtab on a VF page), and when a subtab is focused, I need the fired event to send this information so the primary tab highlight panel can grab it.

I am aware of the sforce.console.onFocusedSubtab() method, however, the issue with this is that the event will fire for every subtab that is open. So if 2 opportunity subtabs are open for one account, when one of those subtabs is focused, the events will be fired from both subtabs.

Here is a code snippet for what I currently am attempting.

 window.onload = function(){
    console.log('opp real time onload');
    sforce.console.onFocusedSubtab(fireEvent);
}

var fireEvent = function(result){   
    var oppID = '{!Opportunity.Loan_Number__c}';
    sforce.console.fireEvent( 'oppLoad', oppID);
}

When switching between subtabs, you can see the console output below:

message from real time 8952375
message from real time 1520493

When switching between a subtab once, both events are fired (I have two subtabs open). Which, clearly, I know this is because of the onFocusedSubtab() console method.

So my question is, does anyone have any suggestions how I can go about getting the event to fire only from the focused subtab?

Thanks in advance, and any suggestions/comments would be much appreciated.

EDIT

I should probably mention that I have tried to use getFocusedSubtabId() in conjunction with onFocusedSubtab(). The thing about that is when onFocusedSubtab() is called, it gets called from every tab. So when getFocusedSubtabId() gets called after, the result from onFocusedSubtab() will already contain the ID from the currently focused tab. So when getFocusedSubtabId() is called, it will contain the same ID.

Quoted from SF:

    onFocusedSubtab() response:  "The ID of the subtab on which the browser is focused."
  • Hi all, does anyone have any suggestions? – OzZiE Nov 5 '15 at 5:17
0

I hope you're not still exploring this, but you should use onFocusedSubtab on the highlights panel as follows:

sforce.console.onFocusedSubtab(function (rsp) {
  generateDetails(rsp.objectId);
}

where you've defined generateDetails in the highlights panel.

Your problem is that onFocusedSubtab is a listener - it listens for events. Therefore you should subscribe to the event only where it's relevant.

I guess another way to do it would be to say in the subtab:

sforce.console.onFocusedSubtab(function (rsp) {
  if (rsp.id === mytabId) {         // or rsp.objectId === "{!opportunity.Id}"
  fireEvent('oppLoad', generateDetails(rsp.objectId));
}
|improve this answer|||||

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.