- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 03:21 AM
Hi Guys,
I'm having my first go at an instance with multiple languages set up and having an issue with gs.getMessage() returning only English messages in notifications even though I have translated messages. I have tried logging in selecting other language and having other language set on a user record but still all I see is English messages.
Below are my translated messages.
Email script name: (chubb_message)
var msg=gs.getMessage('chubb_message');
email.setSubject(msg);
Notification: Message HTML field
Please any one suggest me on this?
Any help would be much appreciated!!
Regards,
NJ
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 05:12 AM
Short answer: The notification processing is happening in the background as the system account. It doesn't know what language the user is unless you tell it. If you are triggering the notifications from events, you can pass one of the parameters and then use that to get the proper message.
The approach I have used in multi-lingual is less elegant, but never failed. I trigger notifications from an event (ex: gs.eventQueue('my.notification', current, '', ''))
Then I have a notification for each language and a condition that checks the recipient's language. For example, if the message is going to the incident caller. These all respond to the same event trigger, but only the one matching the proper conditions gets sent.
Notification: Incident commented - EN
Condition: Caller.Language | is | English
(English subject and body)
Notification: Incident commented - FR
Condition: Caller.Language | is | French
(French subject and body)
and so on...
http://wiki.servicenow.com/index.php?title=Events_and_Email_Notification
Email Notifications - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 08:20 AM
I posted a solution for this in the Ideas portal, here:
https://community.servicenow.com/community?id=view_idea&sysparm_idea_id=65d616bddba444100be6a345ca961986&sysparm_idea_table=x_snc_com_ideation_idea&sysparm_module_id=enhancement_requests
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2020 06:05 AM
HI Andy,
I went through the solution you wrote in the idea Portal. can you see my idea here below?
How about changing system language when executing the mail script?
For Example, in the below script i have set system language to japanes and at the end chanage back to initial language.
can you see if there is any risk here?
(function runMailScript(current, template, email, email_action, event) {
var util = new I18nUtils();
var currentLanguage = util.getLanguage();
util.setLanguage('ja');
template.print('<p><font size="4" color="#999999" face="helvetica"><strong>');
template.print(gs.getMessage('Additional Details:'));
template.print('</strong></font></p>');
template.print('<font size="3" color="#999999" face="helvetica">');
var i18nCaller = gs.getMessage('Caller: {0}', '${caller_id}');
var catg= current.getElement('category').getChoiceValue();
var seve= current.getElement('severity').getChoiceValue();
var prio= current.getElement('priority').getChoiceValue();
var i18nCagegory = gs.getMessage('Category: {0}', catg);
var i18nSeverity = gs.getMessage('Severity: {0}', seve);
var i18nPriority = gs.getMessage('Priority: {0}', prio);
template.print('<p>' + i18nCaller + '<br/>');
template.print('<p>' + i18nCagegory + '</p>');
template.print('<p>' + i18nSeverity + '</p>');
template.print('<p>' + i18nPriority + '</p>');
template.print('</font>');
util.setLanguage(currentLanguage);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2020 06:47 AM
Also i observed, that getEmailRecipientUsers() isnot defined in your solution. Can you please help with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 02:54 AM
Hi vishurajm,
Setting the system language on-the-fly seems a bit drastic, and I wouldn't be comfortable doing that myself. What would be the impact on other messages that may be running concurrently?
Here's the missing script include:
function getEmailRecipientUsers(current, email_action, event){
var i = 0;
var arrayUtil = new ArrayUtil();
var userArr = [], noDups = [], fullUsers = [];
//Check for recipients added directly by name
var userRecipients = email_action.recipient_users.toString().split(',');
if(userRecipients)
{
for(i=0; i<userRecipients.length; i++)
{
userArr.push(userRecipients[i]);
}
}
//Check for recipients added by ServiceNow groups
var groupRecipients = email_action.recipient_groups.toString().split(',');
if(groupRecipients)
{
for(i=0; i<groupRecipients.length; i++)
{
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group',groupRecipients[i]);
gr.query();
while(gr.next())
{
userArr.push(gr.getValue('user'));
}
}
}
//Check for recipients added by fields (such as Assigned To, Requested By, etc)
var fieldRecipients = email_action.recipient_fields.toString().split(',');
if(fieldRecipients)
{
for(i=0; i<fieldRecipients.length; i++)
{
var singleFieldRecipient = fieldRecipients[i].toString();
userArr.push(current.getValue(singleFieldRecipient));
}
}
//Check for recipients in both of the optional event_parm fields
if(email_action.event_parm_1!='')
{
userArr.push(event.parm1);
}
if(email_action.event_parm_2!='')
{
userArr.push(event.parm2);
}
//Remove any duplicates found
noDups = arrayUtil.unique(userArr);
//Loop through the distinct list and return the User objects
if (noDups)
{
for(i=0; i<noDups.length; i++)
{
var gUser = new GlideRecord('sys_user');
gUser.get(noDups[i]);
fullUsers.push(gUser);
}
}
return fullUsers;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2020 08:57 AM
Hi Andy, Thanks for the script. It was helpful
Also i found "applyStandardEmailTextFormatting" function. Do you have any code?