function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ssoftwaressoftware 

Opening an article as a subtab in the service cloud console

Hi All,

 

I am using the following formula field to open a knowledge article.

 

HYPERLINK('/knowledge/publishing/articleOnlineDetail.apexp?id='+ artcle_id, 'Sample Article')

 

Can one of you let me know how I can adapt it so that it opens as a subtab in the service cloud console?

 

Thanks

Madhav

Best Answer chosen by Admin (Salesforce Developers) 
ssoftwaressoftware

Hi Vikash,

 

The following code I wrote worked for me. Please note that it only works when you click on the Title while you are viewing the Case in the Service Cloud Console.

 

Kind Regards

Madhav

 

<apex:page standardController="Case" sidebar="false" showheader="false">

    <apex:includeScript value="/support/console/27.0/integration.js"/>

    <script type="text/javascript">

       function openPrimaryTab() {

           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 ,

               '/{!JSENCODE(Case.Knowledge_Article__c)}', true,

               '{!JSENCODE(Case.Title__c)}', null, null, 'ArticleSubtab');

       };

 

    </script>

<apex:form >

    <apex:commandlink style="margin-left:0px;color:#000;font-size:11px;" onclick="openPrimaryTab();return false;" value="{!Case.Title__c}" />

</apex:form>

</apex:page>

All Answers

Shannon HaleShannon Hale

I'm not sure this can be done. The console uses JavaScript to instantiate each tab and set its content, you would need to be able to access the page JavaScript in the page through the button. This is generally not a good idea as you can't rely on the page ID, content and code not to change if it's not exposed through an actual API.

ssoftwaressoftware

Hi Shannon,

 

Thank you for your reply. I appreciate it. I will check out the Service Cloud console integration toolkit to see if a different solution can be found.

 

Kind Regards

Madhav

Vikash TiwaryVikash Tiwary

Hi

 

Did you find solution to your question? I am also facing similar problem. I am able to open article page as sub tab from my service console by passing '/knowledgeArticleId' as url to openSubTab() method,  however this article page differs from the standard Page that is being opened from Standard suggested article Section. My requirement is to get similar article page opened as subtab from my custom Console component as in the case it is opened from suggested article section.

 

Any help would be highly appreciated

Thanks

ssoftwaressoftware

Hi Vikash,

 

The following code I wrote worked for me. Please note that it only works when you click on the Title while you are viewing the Case in the Service Cloud Console.

 

Kind Regards

Madhav

 

<apex:page standardController="Case" sidebar="false" showheader="false">

    <apex:includeScript value="/support/console/27.0/integration.js"/>

    <script type="text/javascript">

       function openPrimaryTab() {

           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 ,

               '/{!JSENCODE(Case.Knowledge_Article__c)}', true,

               '{!JSENCODE(Case.Title__c)}', null, null, 'ArticleSubtab');

       };

 

    </script>

<apex:form >

    <apex:commandlink style="margin-left:0px;color:#000;font-size:11px;" onclick="openPrimaryTab();return false;" value="{!Case.Title__c}" />

</apex:form>

</apex:page>

This was selected as the best answer
Vikash TiwaryVikash Tiwary

Hi Madhav,

 

It seems you have custom field on Case but in our case we dont have that field. I tried the same merge field as above on click of article title but even that opens just article page as Subtab not like native article page as opened in Standard knowledge article.

Anyways thanks for the quick response.

 

Thanks.

 

ssoftwaressoftware

Hi Vikash,

 

You are correct. I have a custom field called Knowledge_Article__c in the Case object which stores the ID of the article. Title__c is just a text field storing the article name.

 

The visualpage need to be added to the Case page layout and its height set to around 17 or so - so that it looks like other fields in the layout. Thus when you click on the title link (from the service cloud interface), the visualforce page gets the case Id - from which its accesses the appropriate knowledge article id, and then displays the article as a subtab.

 

/Madhav