gs.getDisplayValue() should show the value in English

Uttam Sai
Tera Contributor

Hi Team,

 

We have a requirement in a Record Producer where there are choices for a select box fields which are translated to user's session Language. And we have been using a script to populate the short description using those choices . 
Our requirement is that the choices should be in Translated Language(source user's language) but The short description shouldn't be Translated. It should be in English.

I have been using the below script but it doesn't work.

I have been trying below script , but the value of the producer short description is still in session language . Could you please help .

 

var lang = gs.getSession().getLanguage();

if (producer.problem_subcategory_team_center.getDisplayValue() == 'OTP') {
    gs.getSession().setLanguage("en");
    short_desc = producer.product_line.getDisplayValue() + ' - ' + producer.issue_category.getDisplayValue();
    gs.getSession().setLanguage(lang);
else {
    short_desc = producer.problem_short_description;
}

 



4 REPLIES 4

Sayali Gurav
Tera Guru
Tera Guru

Hello @Uttam Sai ,

You can try by using this code in your script :

 

var lang = gs.getSession().getLanguage();

if (producer.problem_subcategory_team_center.getDisplayValue() == 'OTP') {

    gs.getSession().setLanguage("en");

    current.short_desc = producer.product_line.getDisplayValue() + ' - ' + producer.issue_category.getDisplayValue();

    gs.getSession().setLanguage(lang);

} else {

    current.short_desc = producer.problem_short_description;

}

 

If this will helps you please mark helpful as well as accept as solution.

Thanks & Regards,

Sayali Gurav

Hi @Sayali Gurav ,

 

This looks like the same one that i have mentioned in the question. Could you please help me understand , where i am doing wrong.

 

Thanks 
Uttam Sai

No it is not same, I have added current keyword before the field name in if/else block e.g. 

    current.short_desc = producer.problem_short_description;

Try by using this code, it will work.

Robbie
Kilo Patron
Kilo Patron

Hi @Uttam Sai,

 

Did you see my earlier response?

Another community member has nicely provided a solution found in the link below.

 

To help others (or for me to help you more directly), after checking the link below, please come back and mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

https://www.servicenow.com/community/developer-forum/how-to-get-the-label-name-of-a-specific-languag...