Other language translated Kb articles are showed on incident related search results

Madankumar N1
Tera Contributor

Hi
We have enabled translated articles when one article translated to another language it is created two article one is English and another one is Spanish
When am creating incident if i provide short description which will match of articles it is showing both articles 
I need to show based on user language 

if User spanish it has to show spanish translated articles 

if user is English then it needs to show only English Language articles
How we can achieve this scenario

5 REPLIES 5

Rajdeep Ganguly
Mega Guru

To achieve this scenario, you can follow these steps: 1. First, you need to ensure that the user's preferred language is set correctly in their user profile. This can be done by navigating to the user's record and setting the 'Preferred Language' field to the appropriate language. 2. ServiceNow uses this 'Preferred Language' field to determine which language to display content in, including Knowledge articles. If a translated version of an article exists in the user's preferred language, that version will be displayed. 3. For the Knowledge search functionality specifically, you can customize the search conditions to filter out articles that are not in the user's preferred language. This can be done by modifying the 'Knowledge - Search' business rule. 4. In the 'Knowledge - Search' business rule, you can add a condition to the search query that checks the language of the article against the user's preferred language. This can be done using the 'language' field of the Knowledge article and the 'preferred_language' field of the user record. 5. Here is a sample code snippet that you can use as a reference: javascript var userLanguage = gs.getUser().getPreference('language'); var knowledgeQuery = new GlideRecord('kb_knowledge'); knowledgeQuery.addQuery('language', userLanguage); knowledgeQuery.query(); 6. This code will return only the Knowledge articles that are in the same language as the user's preferred language. 7. After modifying the business rule, make sure to test the functionality with different users and preferred languages to ensure that it is working as expected. Remember, modifying out-of-the-box business rules can have unintended side effects, so it's always a good idea to test thoroughly and have a rollback plan in place.