easy way to add a couple knowledge bases to your service portal search?

wbwb
Tera Expert

Is there really still no way to add additional knowledge bases to your service portal's search feature?  Seems like this should be a simple configuration but everything I'm pulling up in my research suggests I have to customize this.  We're using Jakarta.

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

This query is going against the database so any exceptions need to be "spelled" out in the code.  You could add a "dot-walk" query around the same lines you were editing to filter only on active knowledgebases, but dot-walk queries cause table scans since it has to loop through all articles looking for ones where the knowledgebase is active.  Depending on how many articles you have this could get expensive and cause performance issues.

 

How many KB's are you wanting to search?  All of them or do you have a limited set?  There may be a better way to gather the list of active knowledgebases to pass into this query.

Otherwise, a better You can add a check within the loop to see if the knowledgebase is active and if not continue past this article.  So you would edit lines 15-16 in the script pasted above with:

        // Does user have permission to see this item?  Is the knowledgebase active?
        if (!$sp.canReadRecord("kb_knowledge", kb.getUniqueValue()) || !kb.kb_knowledge_base.active)
            continue;

 

Please mark this post or any as helpful or the correct answer to your question so others viewing this thread can benefit.

View solution in original post

9 REPLIES 9

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Its possible by modifying the search source code.  See this thread for details on a recent similar question:

https://community.servicenow.com/community?id=community_question&sys_id=0ba77c1fdb61d3003882fb651f96...

wbwb
Tera Expert

Thanks Michael.  I saw your answer listed and accepted.  Where exactly does this code go?

 

 

var kbQuery = kb.addQuery('kb_knowledge_base', $sp.getValue('kb_knowledge_base')).addOrCondition('kb_knowledge_base', 'KB-2-SYSID').addOrCondition('kb_knowledge_base', 'KB-3-SYSID');

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Goes into the Portal's search source.

Navigate to Service Portal \ Search Sources and you will find 3 out of the box records.  The Knowledge base record is the one you need to modify.  Open that record and you will need to modify the Data fetch script, out of the box line 7 where its querying for a specific kb_knowledge_base record.

wbwb
Tera Expert

Here's what I have.  I'm not sure if this is ootb or not.  If it is I can just add this line of code at the end of line 7?

 

.addOrCondition('kb_knowledge_base', 'KB-2-SYSID').addOrCondition('kb_knowledge_base', 'KB-3-SYSID');

 

with KB-2-SYSID and KB-3-SYSID as the sys id's of the KB's I want to add.

 

find_real_file.png