Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

I want to display knowledge article based on user language

Adarsh kumar si
Tera Contributor

There is one requirement to show knowledge article to users only of their language on ESC portal (i.e. If user language is Dutch / French then Kb Article should only be visible by user on ESC portal) .  We are using Widget "Knowledge featured articles" to display the articles.

As per current OOB Users are able to see the articles from different language as well.

Can anyone help me on achieve this requirement?


Thank you

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

https://www.servicenow.com/community/developer-forum/displaying-kb-articles-according-to-the-languag... 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0868940

 

Instructions

You can dynamically set the article language based on the user preferred language by setting a dynamic default value into the language field dictionary.


This can be done by following the steps below:

Create a 'Dynamic Filter Option' record to get the 'preferred_language' for the current user.

  1. Go to 'System Definition > Dynamic Filter Options' and create a new record.Add a label such 'User Preferred Language'.
  2. If you want to use the language selected at the user profile (sys_user_preference), simply set the 'Script' field with 'user.language'.
  3. If you want to use the 'Preferred Language' set in the user record (sys_user), then set the 'Script' field to query the user preferred language i.e.: gs.getUser().getRecord().getValue('preferred_language');
  4. Set the field type to 'String'.
  5. Save it.


Update the dictionary to use the above 'Dynamic Filter Option'.

  1. Open the 'language' sys_dictionary record related to the 'kb_knowledge' table.
  2. Find the 'Default Value' tab and check the 'Use dynamic default' option.
  3. In the 'Use dynamic default' select the 'Dynamic Filter Option' record you just created.
  4. Save it.

 

Now next time a user creates a new article, the article language will be set based on the user preferred language.
If the user has no preferred language set, then the language will be set to empty in the article.

Another option is to create a client script that will automatically set the knowledge language based on the user language.
You can use the 'g_lang' variable to get the user language i.e.: g_form.setValue('language',g_lang);

In that case, for the client script to work you may need to add the 'Language' field into the knowledge form.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Tanushree Maiti
Kilo Patron

Hi @Adarsh kumar si ,

 

1 Ensure System property glide.knowman.enable_multi_language_search is set to false

2. KB0696617 Knowledge article in a specific language is displayed regardless the language selected fro... 

3. KB0831958 In Service Portal, switching to a different language will display both English and transla... 

4. https://www.servicenow.com/community/developer-forum/displaying-kb-articles-according-to-the-languag...

 

 

Also you can check: KB2080419 View knowledge articles in various languages all together in the KB portal 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: