Notifications

38 views

Description

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 (nav_to.do?uri=/$knowledge.do), 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

Workaround

  1. Navigate to the "Search Source - Knowledge base" record
    • sp_search_source.do?sys_id=c6170ae86721220023c82e08f585efe6&sysparm_record_list=^ORDERBYname&sysparm_record_target=sp_search_source&sysparm_record_row=1&sysparm_record_rows=3

  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('language',gs.getUser().getLanguage());
kb.addQuery('123TEXTQUERY321', query);
kb.setLimit(data.limit);
kb.query();
data.article_count = kb.getRowCount();

var kbCount = 0;
while (kb.next() && kbCount < data.limit) {
// 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.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;
results.push(article);
kbCount++;
}
$sp.logSearch('kb_knowledge', data.q, kb.getRowCount());

return results;
})(query);

Related Problem: PRB827203

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-05-21 11:44:07
Published:2019-05-16