1

I followed the example provided on this link.

I am trying to open a knowledge article on a new sub-tab in the Service Console, the sub-tab does open but it does not display any content. It keeps 'processing' but nothing appears.

I also tried to replace the article's link to the one generated by the service console but I got the same results.

<apex:page standardController="Case">

<A HREF="https://cs80.salesforce.com/articles/en_US/Procedure/No-Icon/p" onClick="testOpenSubtab();return false">
    Click here to open a new subtab</A> 

<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript">
    function testOpenSubtab() {
        //First find the ID of the primary tab to put the new subtab in
        sforce.console.getEnclosingPrimaryTabId(openSubtab);
    }

    var openSubtab = function openSubtab(result) {
        //Now that we have the primary tab ID, we can open a new subtab in it
        var primaryTabId = result.id;
        sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 
            'salesforce', null, openSuccess, 'salesforceSubtab');
    };

    var openSuccess = function openSuccess(result) {
        //Report whether we succeeded in opening the subtab
        if (result.success == true) {
            alert('subtab successfully opened');
        } else {
            alert('subtab cannot be opened');
        }
    };
</script>

  • 1
    Did you add salesforce.com in whitelisted domains from your console app settings? – tugce Dec 22 '16 at 13:19
  • @tugce Yes I did... – Json Dec 22 '16 at 14:31
2

You're misunderstanding the basic HTML and JavaScript behind this.

<A HREF="https://cs80.salesforce.com/articles/en_US/Procedure/No-Icon/p" onClick="testOpenSubtab();return false">
Click here to open a new subtab</A>

This is not meant to OPEN whatever link you have in the href. This is just a link that trips the function testOpenSubtab()then returns false, which means it is performing the onClick then not navigating to the href location, so it doesn't matter what is in that attribute.

The link it is actually opening is the second argument of openSubtab(), which in the example is "http://www.salesforce.com".

So this would work for your example:

sforce.console.openSubtab(primaryTabId , 'https://cs80.salesforce.com/articles/en_US/Procedure/No-Icon/p', false, 
        'salesforce', null, openSuccess, 'salesforceSubtab');
| improve this answer | |
  • you are right! this is a bit confusing to put onclick function within an a tag! anyway, thanks a lot! – Json Dec 23 '16 at 17:18

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.