0

I am using a custom channel display for my article types. On the page that I have created to show this article, I am using the articleRendererToolbar so that users can vote, chatter, add topics, etc. In the standard Tab view for a knowledge article, a button for users to attach to case is available on the toolbar. However, it is not in mine. Currently there are no attributes listed on the Docs that relate to this button.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_knowledge_articleRendererToolbar.htm

Code

<apex:page standardController="Public__kav" showHeader="false" standardStylesheets="false" applyBodyTag="false" sidebar="false">
    <knowledge:articleRendererToolBar articleId="{!$CurrentPage.parameters.id}" showChatter="true" />
</apex:page>

What do I need to do in order to have this button be available to my users?

1

2 Answers 2

0

There isn't an option within the toolbar to do this, you will need to create it manually.

create an extension for your visualforce page:

global class KCSAttachtoCaseController {

public string caseID{get;set;}
public string kaID{get;set;}

public KCSAttachtoCaseController(ApexPages.StandardController stdController) {
    caseID = ApexPages.currentPage().getParameters().get('caseid');
    kaID = ApexPages.currentPage().getParameters().get('id');
}

public void attachToCase(){
    CaseArticle ca = new CaseArticle();
    ca.CaseID = caseID;
    ca.KnowledgeArticleId = kaID;
    insert ca;
}

}

Then in your visual force page add the following:

    <knowledge:articleRendererToolbar articleId="{!$CurrentPage.parameters.id}" canVote="true" showChatter="true">
        </knowledge:articleRendererToolbar>
        <br /><br />
        <knowledge:articleCaseToolbar rendered="{!$CurrentPage.parameters.caseId != null}"
        caseId="{!$CurrentPage.parameters.caseId}"
        articleId="{!$CurrentPage.parameters.id}"></knowledge:articleCaseToolbar>

        <apex:form rendered="{!$CurrentPage.parameters.caseId != null}">
  <div style="margin:5px">
  <apex:commandbutton value="Attach and Return to Case" action="{!attachToCase}" oncomplete="ReturntoCase();"/>
  </div>
  </apex:form> 

I set this up to only display the attach to case button if the caseid was passed to the article to avoid errors.

2
  • Also don't forget to add the extension to your page as well.
    – Bob Cruz
    Apr 19, 2016 at 12:58
  • did you pull your answer from here? developer.salesforce.com/forums/?id=906F000000097YeIAI I don't really want the knowledge:articleCaseToolbar on there at all. Also, is returnToCase(); a globally defined function? I don't see it in your code
    – tekstrand
    Apr 19, 2016 at 14:25
1

@TheElks I might have used or referenced that forum answer when I setup our org, it has been a while. Anyway if you don't want the knowledge:articleCaseToolbar just remove that section from the page. The returnToCase() was a simple javascript function I added to the end of the page.

  <script language="JavaScript">
caseId = "{!$CurrentPage.parameters. caseId}";

function ReturntoCase(){
   window.location.assign("/" + caseId);
   } 
</script>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .