How to include multiple knowledge base in service portal

RudhraKAM
Tera Guru

Hello , as many of you know that we can only assign one knowledge base in service portal , how to include another knowledge base too ?

My issue with this is, If i have knowledge base A and  in the portal search if i search for some thing which is in that knowledge base it will display that 

but if i want to include knowledge base B as well in the portal search , how can i do that 

 

I tried adding the search source too but no luck , can some one suggest me what to do with this ?

1 ACCEPTED SOLUTION

OK if you want to set specific KBs, change that line to something like the following:

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');

The idea is KB1 is set in the service portal definition record and the addOrCondition statements add others.

View solution in original post

18 REPLIES 18

Well I feel silly, never really inspected the search source code too well, comment out this line of the Data fetch script (line 7 oob):

//kb.addQuery('kb_knowledge_base', $sp.getValue('kb_knowledge_base'));

 

That is what is telling the search to ONLY use the knowledge base defined in the Service Portal definition record.  I just tested in my demo instance and results from other KBs are now showing.

Edit:

 

Warning: If you have other portals that you only want to search a particular knowledge base defined in the Service Portal definition record, you may want to clone the Knowledge Base search source and define your own for this particular portal.  That way other portals leveraging this search source aren't impacted.

Thanks 

Now imagine i have 2 knowledge base A and B 

what code should i need to add in order for the search to show only from those 2 knowledge base ?

 

like comment out line 7 and can i add 

kb.addQuery('kb_knowledge_base', "sysid of A" , "sys ID of B");

please correct me if syntax is wrong 

OK if you want to set specific KBs, change that line to something like the following:

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');

The idea is KB1 is set in the service portal definition record and the addOrCondition statements add others.

how about if we dont wann define the Knowledge base in the portal properties but define it in search sources 

 

will this be correct solution ?

 

 

 

(function(query) {
var results = [];
//Here goes the logic. Compute results however you want!
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('workflow_state', 'published');
kb.addQuery('valid_to', '>=', (new GlideDate()).getLocalDate().getValue());
//kb.addQuery('kb_knowledge_base', $sp.getValue('kb_knowledge_base'));

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

kb.addQuery('123TEXTQUERY321', query);
kb.setLimit(data.limit);
kb.query();
data.article_count = kb.getRowCount();

That is correct.