How to check logged in user Language in Server side

Kri
Tera Guru

I want to check Logged in user language in Server side. I wrote the below script but it is not working

if(gs.getSession().getLanguage()=='English'){
return 'Test message'
}
1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @Kri 

 

gs.getSession().getLanguage() is correct and will give you the language opted by  Logged in user

 

The issue here is you are trying to match it to English which is incorrect. The reason being servicenow stores language preference in terms of language code. 

So for English, language code is en

 

Similarly you can find the code for other languages in below link

http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

View solution in original post

2 REPLIES 2

Manmohan K
Tera Sage

Hi @Kri 

 

gs.getSession().getLanguage() is correct and will give you the language opted by  Logged in user

 

The issue here is you are trying to match it to English which is incorrect. The reason being servicenow stores language preference in terms of language code. 

So for English, language code is en

 

Similarly you can find the code for other languages in below link

http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

Kri
Tera Guru

Perfect! thanks