--- title: Implement a Create Knowledge Article button slug: '3402' canonical_url: https://docs.coveo.com/en/3402/ collection: coveo-for-servicenow source_format: adoc --- # Implement a Create Knowledge Article button Once a case or an incident is solved, your customer support agents may want to create a knowledge article for future reference. To help them accomplish this task, you can implement a "Create Knowledge Article" button thanks to ServiceNow's [UI actions](https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/list-administration/concept/c_UIActions.html). The button appears on the case or incident form and acts as a shortcut to open a knowledge article creation form. Alternatively, you can add this button to the [Insight Panel](https://docs.coveo.com/en/2113/) that appears in case or incident forms. ## Creating a UI action (recommended) To implement a Create Knowledge Article button in your case and/or incident forms, follow the [instructions in the ServiceNow documentation](https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/list-administration/task/t_EditingAUIAction.html). Configure your UI action as follows: . Check the **Client** box. . Check the **Form button**, **Form content menu**, and/or **Form link** boxes to determine where the button will appear. . In the **Onclick** box, enter `redirectToCreateKB()`. . In the **Script** box, enter the JavaScript code to execute when a user clicks the button. Adapt the sample below to your needs. The `g_form.getValue` function allows you to reuse the desired incident/case form values in the knowledge article. With the `logCustomEvent` function, Coveo logs the knowledge article creation, which then contributes to make the case or incident appear higher in search results, as it's considered more relevant. ```javascript function redirectToCreateKB() { var title = g_form.getValue("short_description"); var caseId = g_form.getUniqueValue(); var coveoRoot = document.querySelector("#search"); var event = { name: 'createKbFromCase', type: 'case' }; Coveo.logCustomEvent(coveoRoot, event, { caseId: caseId }); var query = "short_description=" + title + "^source=" + caseId; window.open("/kb_knowledge.do?sys_id=-1&sysparm_query=" + encodeURIComponent(query), "_blank"); } ``` ## Adding the button to an Insight Panel . In the Coveo Administration Console, on the [**Search Pages**](https://platform.cloud.coveo.com/admin/#/orgid/search/search-pages/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/search/search-pages/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/search/search-pages/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/search/search-pages/)) page, click the desired page, and then click **Edit interface** in the Action bar. . In the [Interface Editor](https://docs.coveo.com/en/1852/), switch to the code view, and then add the following code to your page: ```html
``` . Optionally, you can add a script underneath to reuse the desired incident/case form values in the knowledge article. Adapt the following sample to your needs. ```html ```