f you’ve worked with ServiceNow much at all, you’re probably familiar with the capability provided to search knowledge from the incident form, and then attach the knowledge article back to the originating incident. This behavior is extremely useful and can be customized if needed. One complaint I’ve heard about this behavior before is that it posts back the entire contents of the knowledge article into the ‘Comments’ field on the incident. The advantage to this setup is that the solution then gets sent directly out to the end user in their email, but it also comes with a disadvantage since the user never actually has to interact with the Knowledge Base or even know that they could have found their solution there.

One way to better promote knowledge use among your end user community (while still providing useful solutions) is to customize this default attach behavior to send a link to the knowledge article rather than the full text in the Incident ‘Comments’ field. In this article, I’ll show you how that can be done!

Attach Knowledge Link

While this solution works perfectly, it does require you to update or override an out-of-box script include. As such, you’ll want to make a note of the modification and evaluate it during upgrades.

You’ll only need to change a single record to make this modification. Navigate to ‘System Definition -> Script Includes’ in your left nav and open the ‘KnowledgeAjax’ script include. Look for the following chunk of code (which is responsible for returning the full KB article text to the incident form) and comment it out…

var s = "Knowledge article " + article.number + ":\n";
if (gs.getProperty("glide.ui.security.allow_codetag", "true") != "true")
   s += article.short_description;
else {
   var displayValue = new KnowledgeHelp(article).findDisplayValue();
   s += "[code]" + displayValue + "[/code]";

Then, directly above or below that code, paste the following code and update the record…

//Return a link to the knowledge article instead of the full article text
var s = "Knowledge article " + article.number + ":  " + article.short_description + "\n";
if (gs.getProperty("glide.ui.security.allow_codetag", "true") != "true")
   s += gs.getProperty('glide.servlet.uri') + "kb_view.do?sysparm_article=" + article.number;
else {
   s = "Knowledge article ";
   s += '[code]<a href="' + gs.getProperty('glide.servlet.uri') + 'nav_to.do?uri=kb_view.do?sysparm_article=' + article.number + '" style="color:blue">' + article.number + '</a>[/code]' + ":  " + article.short_description + "\n";

Fuji and beyond!

Fuji instances introduce a dynamic search functionality that allows you to attach articles from a dynamic search component underneath the ‘Short Description’ field. For some reason, ServiceNow has changed the location of the attach code for the new components (even though the code is largely the same) to a script include named ‘cxs_Knowledge’. Unfortunately, they’ve also put a read-only protection policy on the script include so you can’t edit it! In order to get this to work in a Fuji instance, you’ll need to override the ‘cxs_Knowledge’ script include by creating an exact duplicate copy…same name, same code, etc. Then, follow the procedure described above to replace the code within your new ‘cxs_Knowledge’ script include.

If you’ve updated the record correctly, you should be able to see the results by testing the attach knowledge functionality from the incident screen.