Knowledge Search in Service Portal does not restrict results to the user's selected language

Steps to Reproduce

  1. Login into an Out-of-box Helsinki Patch 7 instance
  2. Make sure the plugin:'I18N: Knowledge Management Internationalization Plugin v2', is activated
  3. Create a KB article in language English and also create a child article using the translated version tab in another language E.g. German
  4. In the Knowledge Search ($, users have the option to select a language for search and the articles are searched based on the language selected
  5. Change the language from the System Settings (e.g. English to German)
  6. Go to Service Portal and do knowledge search, all articles irrespective of language will be displayed


  1. Navigate to the "Search Source - Knowledge base" record

  2. After line 7 from the field 'Data fetch script' found under the section 'Data Source'. add the code:
    • kb.addQuery('language',gs.getUser().getLanguage());

  3. Save the record

The entire code block should then look like this:

(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'));
kb.addQuery('123TEXTQUERY321', query);
data.article_count = kb.getRowCount();

var kbCount = 0;
while ( && kbCount < data.limit) {
// Does user have permission to see this item?
if (!$sp.canReadRecord("kb_knowledge", kb.getUniqueValue()))

var article = {};
$sp.getRecordDisplayValues(article, kb, 'sys_id,number,short_description,published,text');
article.publishedUTC = kb.getValue('published');
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());
article.label = article.short_description;
article.primary = article.short_description;
$sp.logSearch('kb_knowledge', data.q, kb.getRowCount());

return results;

Related Problem: PRB827203

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-01-29 03:16:32