You are here:
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 You can also create a custom article widget with
support:caseArticle.
- From the object management settings for cases, go to Buttons, Links, and Actions.
- Click New Button or Link.
- Enter a unique Label, Name, and Description.
- Select Detail Page Button for Display Type.
- Select Execute JavaScript in the Behavior dropdown.
- Select OnClick JaveScript in the Content Source dropdown.
-
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; - Click Save.
- From the object management settings for cases, go to Page Layouts.
- Click Edit next to Case Layout.
- Drag your custom button for article search into the case layout.
- Click Save.
-
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> - Back in the Buttons, Links, and Actions area for cases, click Edit next to View.
- Select Visualforce Page in Override with.
- Select CaseDetailsWithoutStandardKBSearchButton from the dropdown.
- Click Save.
Did this article solve your issue?
Let us know so we can improve!

