Displaying Kb articles according to the Language in Language Picker

salomesimpsone
Giga Contributor

Hi All,

In service portal, we have a widget called "Language Picker" that allows the user to switch between the Languages.

But My need is to display the KB articles according to the switched Language

For example, if user selects 'Japanese' in Language Picker, the Kb articles in Japanese Language must only be visible to the User

Can anyone help on this??

Thanks in Advance

1 ACCEPTED SOLUTION

Hi Robbie,



As of my understanding, the "Language Picker" widget in the Service portal is working as below:



i)When user selects a specific language in the "Language picker", the "Language(preferred_language)" field in "Sys_user"   table is getting updated



So,In "KB View 2" widget, I just added the below code to get 'Language' field Value



data.language = gs.getUser().getLanguage();--->(In server script)



And queried it in 'kb_knowledge' table(In 'getDocuments()')


View solution in original post

9 REPLIES 9

Robbie
Kilo Patron
Kilo Patron

Hi Salome,


How did you go?



Please mark this response as correct and helpful via your post link (Displaying Kb articles according to the Language in Language Picker) to help others with the same question.



Thanks,


Robbie


Hi Robbie,



As of my understanding, the "Language Picker" widget in the Service portal is working as below:



i)When user selects a specific language in the "Language picker", the "Language(preferred_language)" field in "Sys_user"   table is getting updated



So,In "KB View 2" widget, I just added the below code to get 'Language' field Value



data.language = gs.getUser().getLanguage();--->(In server script)



And queried it in 'kb_knowledge' table(In 'getDocuments()')


Hello Robbie,

 

Can you please elaborate more on this, we also have the language picker enabled in our portal, when users change the language to french they cannot view the knowledge articles written in english and how to make them view the all the knowledge articles irrespective of the language selected in the language picker.

I work in domain seperated instance and do you have any workaround apart from enabling the system property "glide.knowman.enable_multi_language_search".

 

Thanks,

Prerana

ESL
ServiceNow Employee
ServiceNow Employee

Hi Could you provide the detail how your configuration work?

I want to modify kb view2 but it is not avaliable.

I clone KB view2 and add this code in server script.

data.language = gs.getUser().getLanguage();

and added "gr.addQuery('language', data.language);"

function getDocuments(kb) {
	var d = [];
	var gr = new GlideRecordSecure('kb_knowledge');
	gr.addQuery('kb_knowledge_base', kb);
	gr.addQuery('workflow_state', 'published');
	gr.addQuery('valid_to', '>=', (new GlideDate()).getLocalDate().getValue());
//get KB based on user language
	gr.addQuery('language', data.language);
	gr.orderBy('short_description');
	gr.query();

 

but it was not work well.

Please advice.

 

Thank you

 

Robbie
Kilo Patron
Kilo Patron

Hi Salome,


Great - glad we got there? Was my advice helpful? Please mark accordingly.



Thanks,


Robbie