- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2018 11:22 AM
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 ?
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 12:15 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 07:00 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 11:25 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 12:15 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 12:39 PM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 12:56 PM
That is correct.