Use More Case Keywords to Find Articles

When searching knowledge articles from a case, by default, only the case title is used in the search. Often, you want to use information from the case for more accurate search results, or create a custom search button.

Required Editions

Available in Salesforce Classic and Lightning Experience. View supported editions.
User Permissions Needed
To create or change custom buttons or links and create a Visualforce page:

Customize Application

Luckily, Salesforce Knowledge search pages accept other parameters:

  • id=<case id>: The ID of the current case.
  • search=<keywords>: The keywords to be searched.
  • articleType_<article type dev name>=on: multiple parameters possible, article types to select (if no article type is selected, then all article types are selected)
  • ct_<data category group internal name>=<data category internal name>: multiple parameters possible, filter pre-selection

To take advantage of those parameters, add a custom button to the case detail page containing a few lines of javascript that extract keywords from the case and hide the default article search button.

Note
Note You can also create a custom article widget with support:caseArticle. 
  1. From the object management settings for cases, go to Buttons, Links, and Actions.
  2. Click New Button or Link.
  3. Enter a unique Label, Name, and Description.
  4. Select Detail Page Button for Display Type.
  5. Select Execute JavaScript in the Behavior dropdown.
  6. Select OnClick JaveScript in the Content Source dropdown.
  7. Enter code for extracting case data and setting up parameters for the article search page.
    For example:
    // article search page URL
    var url = '/knowledge/knowledgeHome.apexp';
    
    // ID of the current case
    url += '?id={!Case.Id}';
    
    // use the case subject as the search keywords
    url += '&search={!Case.Subject}';
    
    // read case attributes
    var caseType = '{!Case.Type}';
    var caseProduct = '{!Case.Product__c}';
    
    // if the case is of a certain type, select only 2 of the article types available
    // in other cases, we keep the default behavior (all article types selected)
    
    if (caseType=='Problem' || caseType=='Question') {
       url += '&articleType_FAQ_kav=on';
       url += '&articleType_How_To_kav=on';
    }
    
    // preselect a data category for search results based on the category
    
    var product = '';
    if (caseProduct=='Home')
       product = 'Home';
    if (caseProduct=='SMB')
       product = 'Small_and_Medium_Business';
    if (caseProduct=='Large enterprise')
       product = 'Large_Enterprise';
    
    if (product.length>0)
       url += '&ct_Products2=' + product;
    
    // once the logic is executed, we go to the article search page
    window.location = url;
  8. Click Save.
  9. From the object management settings for cases, go to Page Layouts.
  10. Click Edit next to Case Layout.
  11. Drag your custom button for article search into the case layout.
  12. Click Save.
  13. Create a Visualforce page named CaseDetailsWithoutStandardKBSearchButton with the following code:
    <apex:page standardController="Case">
        <style type="text/css">
            div.knowledgeBlock input {display: none}
        </style>
        <apex:detail/>
    </apex:page>
  14. Back in the Buttons, Links, and Actions area for cases, click Edit next to View.
  15. Select Visualforce Page in Override with.
  16. Select CaseDetailsWithoutStandardKBSearchButton from the dropdown.
  17. Click Save.