Notification variable not getting translated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 08:00 AM
Hi,
For translation of notifications, we have created notification in each language(french and english). For one of the french notifications, there are variables added in the message body. This notification is created in the sc_request table.
I have changed the language of the recipient to french in the user table and as well as changed the language in profile to french. Look at the image below, the ui is now in french. The field impact's value is translated here.
However when the notification is triggered, you can see the word, 3 -Medium is not translated. The same word is translated as 3 – Modérée in the above image, which is taken from the sc_request table from which the variable is used in the notification record.
How to fix this and translate that variable's value. The translated value is already available in the sys_choice table, but why it does not appear in the notification still remains unclear (language is set to french both in the user table and in the preferences table) .Any workaround/help is appreciated.
Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 08:27 AM
Hi Kevin,
Try below.
1. Create a mail script as below
name: gettranslatedimpactvalue
(function runMailScript(current, template, email, email_action, event) {
var getreq=new GlideRecord('sc_request');
getreq.addQuery('sys_id',current.sys_id);
getreq.query();
if(getreq.next())
{
var impactis=getreq.impact;
var getimpacttranslated=new GlideRecord('sys_choice');
getimpacttranslated.addQuery('element','impact');
getimpacttranslated.addQuery('name','task');
getimpacttranslated.addQuery('language','es'); //replace es accordingly here
getimpacttranslated.addQuery('value',impactis); //considering impactis returns value as 1,2 or 3 or so
getimpacttranslated.query();
if(getimpacttranslated.next())
{
template.print(getimpacttranslated.label);
}
}
})(current, template, email, email_action, event);
Replace ${impact} in the notification as ${mail_script:gettranslatedimpactvalue}
Above it untested but should work ideally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 08:46 AM
Hi,
Did you check in the actual email body instead of preview?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 10:41 PM
This is not the preview notification, preview notification works fine. The actual mail triggered in the mail table does not translate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 10:46 PM
Is there no other way around for this? why does one variable not get converted when other variables are getting converted?