The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Show all Knowledge bases

jeremyo
Kilo Contributor

Hi,

I am working with the new Service Portal in Helsinki and I want to show all knowledge bases.

But how do I do this? It is only showing IT at the moment.

Knowledge.PNG

11 REPLIES 11

brett_karl
ServiceNow Employee
ServiceNow Employee

Hey Jeremy,


  As Service Portal only allows you to connect to 1 Knowledge Base OOB, this would require a custom solution. If you navigate to Service Portal > Widgets > Search Page (and search nav)



if (data.t == 'kb' || !data.t) {


  var kb = $sp.getKBRecord();


  kb.addQuery('123TEXTQUERY321', data.q);


  kb.setLimit(data.count);


  kb.query();


  data.article_count = kb.getRowCount();


  while (kb.next()) {


  // Does user have permission to see this item?


  if (!$sp.canReadRecord("kb_knowledge", kb.getUniqueValue()))


  continue;



  var article = {};


  $sp.getRecordDisplayValues(article, kb,


'sys_id,number,short_description,published,text')


  article.type = "kb";


  if (!article.text)


  article.text = "";


  article.text = $sp.stripHTML(article.text) + "";


  article.text = article.text.substring(0, 200);


  article.score = parseInt(kb.ir_query_score.getDisplayValue());


  data.results.push(article);


  }


  $sp.logSearch('kb_knowledge', data.q, kb.getRowCount());


}




Line 2 in my example shows we are using $sp.getKBRecord, this grabs that


field that drives the knowledge base you are using. This field exists on Service Portal > Portals > [Your Portal] > Knowledge Base field.



You could convert this to be a list field, then parse the array in the server script, loop through the results and add a glideRecord lookup.



Some other suggestions include:



  • Creating separate Portals for each Knowledge Base using the same pages, headers, themes and widgets, and just a different URL at the top
  • Combine all KB articles into one Knowledge Base
  • Create a Service Portal page with block items, each passing a Knowledge Base parameter to the URL and on the subpage grab the URL and query on it (this would be basically alerting the above code


I hope this helps point you in the right direction.


Thanks!!! 🙂



But i think it is very weird that you only can choose one knowledge base in the new Service Portal.


brett_karl
ServiceNow Employee
ServiceNow Employee

I understand completely that the 1:1 ratio between Service Portal and Knowledge Base can be frustrating. I am currently working on two solutions that I will post to share once they are complete:


  1. Block view of all active Service Catalogs with search capability over all catalogs
  2. Block view of all active Knowledge Bases with search capability over all KBs


Once these are complete, I'll reply to this thread. I'm hoping to be done over the next few days.


On a few of our portals we went through and update all the widgets to support all knowledge bases and all catalogs. It's actually quite a few widgets that need editing, and some of the widgets use server side API's that we do not have access to that need to be circumvented. Now the way it works is, if you specify a catalog it will use it, but if none is specified it will search and use all catalogs and knowledge bases. If you need any help or want to take a look how we did it, just shoot me an email and I'd be glad to help.