0

Does anyone have experience with the Salesforce Console Integration Toolkit, specifically the focusSidebarComponent() function. I have a few different VF pages displayed in the sidebar (CustomerKb (id="CustKbVF" name="CustKbVF"), Announcements) and I want to set up a JS onclick to focus CustomerKb from the Announcements tab. Any suggestions on what I'm doing wrong?

<script type="text/javascript">
function focusCustKb() { 
    sforce.console.focusSidebarComponent(JSON.stringify({componentType:'VISUALFORCE',
                                                         pageName: 'CustKbVF'}), "CustKbVF", focusSuccess);
}
var focusSuccess = function focusSuccess(result) {
    //Report whether going to the tab was successful
    if (result.success == true) {
        alert('Going to the tab was successful');
    } else {
        alert('Going to the tab was not successful');
    } 

};
</script>

<A HREF="#" onClick="focusCustKb();return false">
    Click here to focus Customer Kb</A>     

Screenshot of Console

Screenshot of layout

  • What behavior do you observe? Are you seeing any errors in the javascript console? – Adrian Larson Mar 10 '17 at 19:47
  • @AdrianLarson when I click on the link it stays on the same tab and pops up the announcement "Going to the tab was not successful". There is nothing in chrome's inspect element console when I click the button. – McWiskers Mar 10 '17 at 21:21
  • Done, sorry. New to Stack Exchange. – McWiskers Mar 14 '17 at 21:48
  • The component id is almost certainly not CustKbVF, that's likely your issue. I don't see how to get the correct value though. Hmm... – Adrian Larson Mar 14 '17 at 21:52
  • I tried using > var tabId = sforce.console.getFocusedSubtabId(result); > sforce.console.focusSidebarComponent({componentType:'VISUALFORCE', pageName: 'CustKbVF'}, tabId.id, focusSuccess); But I probably did that wrong. – McWiskers Mar 14 '17 at 22:22
0

I finally figured out what was up. I had incorrect values for the pageName and tabId fields. pageName should have been the actual name of the visualforce page minus the extension (CustomConsoleCustomerKbTab) and not the name="" value. The tabId should have been left blank "". The console will assume it's the current tab if left blank. Works like a charm now!

function focusCustKb() 
{ sforce.console.focusSidebarComponent 
(JSON.stringify({componentType:'VISUALFORCE',
                 pageName: 'CustomConsoleCustomerKbTab'}), "", focusSuccess);}

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.