Knowledge Related Articles

RadZz
Tera Contributor

Hello team,

 

We have widget: Knowledge Related Articles  and this is calling another widget: Knowledge List Widget Template

 

So in the template view we can see english and other language articles as well for display.  But we want to see only user language articles. Depending on the user language only those language articles should be seen. Any idea on this?

 

I tried this in the list view widget: data.languagePreference = $sp.getValue('u_preferred_language');

 

and In the main widget I tried : 

 

var user = gs.getUser();
 var language = user.getLanguage();
 var article = new GlideRecord('kb_knowledge');
 article.get(articleId);
 article.setDisplayLanguage('Language');
gs.print(article.getDisplayValue());

 }

 

 

This is the function in knowledge related articles: 

 

 function getRelatedArticles(article_sys_id) {
 
        var kbService = new KBPortalService();
        var pageID = data.isMESP ? "me_kb_view" : "kb_article_view";
 
 
        if (gs.nil(article_sys_id))
            article_sys_id = kbService.getKnowledgeSysIDByNumber($sp.getParameter('sysparm_article'));
        if (!gs.nil(article_sys_id)) {
            options.knowledge_base = options.knowledge_base || String(kbService.getServicePortalKnowledgeBases($sp.getPortalRecord().url_suffix)) || "";          
// options.language = gs.getUser().getValue('language');
 
//             var result = kbService.getRelatedArticles(options.max_records, options.display_field, options.secondary_fields, options.knowledge_base,
//                 article_sys_id + '', article_sys_id + '', options.source_table, options.source_column, options.target_column, pageID);
var result = kbService.getRelatedArticles(options.max_records, options.display_field,options.language, options.secondary_fields, options.knowledge_base,
                article_sys_id + '', article_sys_id + '', options.source_table, options.source_column, options.target_column, pageID);
 
 
options.result = result;
data.result = result;
            data.template = $sp.getWidget("kb-list-widget-template", options);
        }
        return;
    }

 

@Ankur Bawiskar 

 

TIA 🙂

0 REPLIES 0