Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to check logged in user Language in Server side

Kri
Kilo Sage

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
Kilo Sage

Perfect! thanks