Localization Issue in Notifications Based on Account Language/Region

Gopal14
Tera Contributor

Hi everyone,

I’m facing an issue where the resolution code in my notifications is not being displayed in the correct language. I have resolution codes in multiple languages, and these are based on the Account’s preferred language or Region.

Here’s the scenario:

  • If the region is Germany, the resolution code should display in German.

  • However, in the notification, the resolution code is showing in English despite the region being set to Germany.

I’ve tried the following placeholders in the notification template:

  • ${resolution_code.label}

  • ${resolution_code.getValue()}

  • ${resolution_code.getDisplayValue()}

None of these worked to display the localized resolution code in the correct language.

 

Below is my email Script code:

 

var account = current.account;

var lang = account.u_language;
if (!lang || lang.trim() === '') {
    var region = account.u_region + ''; 
    var regionLangMap = {
        'Germany': 'de',
        'Netherlands': 'nl',
        'UK': 'en'
    };

    
    lang = regionLangMap[account.u_region] || 'en';
}

gs.setSessionLanguage(lang);

var resCodeDisplay = current.resolution_code.getDisplayValue();
resCodeDisplay;

 

I am calling this email script in my notification body:

Lösungs-Code: ${mail_script:resolution_code_basedon_region}

 

How ever, when I am doing preview, even though resolution code exists, it is showing as empty

@Ankur Bawiskar 

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Gopal14 

notification is on which table?

resolution code is drop down? If it's drop down then did you create choices in other language?

share some screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

Notification is on Case table(sn_customerservice_case).

 

Yes, I have created choices in other languages as well

below are in Germany

 

Gopal14_0-1749811756442.png

 

below codes are in english

Gopal14_1-1749811913424.png

 

 

 

@Gopal14 

pass language as parameter to getDisplayValue() and it should fetch in correct language

For Global Scope

AnkurBawiskar_0-1749813629322.png

 

For Scoped app - getDisplayValueLang()

var account = current.account;

var lang = account.u_language;
if (!lang || lang.trim() === '') {
    var region = account.u_region + '';
    var regionLangMap = {
        'Germany': 'de',
        'Netherlands': 'nl',
        'UK': 'en'
    };
    lang = regionLangMap[account.u_region] || 'en';
    var resCodeDisplay = current.resolution_code.getDisplayValue(lang);
// if you are in csm scope then use getDisplayValueLang(lang)
    template.print('Resolution code is' + resCodeDisplay);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

my updated code is 

 

scope is customer service

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Get account from the current task or context
var account = current.account;


var lang = account.u_language;
if (!lang || lang.trim() === '') {
    var region = account.u_region + ''; 
    var regionLangMap = {
        'Germany': 'de',
        'Netherlands': 'nl',
        'UK': 'en'
    };

    
    lang = regionLangMap[account.u_region] || 'en';
}

//gs.setSessionLanguage(lang);

var resCodeDisplay = current.resolution_code.getDisplayValueLang(lang);
template.print('Resolution code is' + resCodeDisplay);


})(current, template, email, email_action, event);