- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 08:59 PM
How to call "Message Key"(Created in sys_ui_message) in Mail Script.
I have created 2 messages with same key name in sys_ui_message table.
One message for "English" and the other one for "Japanese". I have selected language as English and Japanese.
When I'm using above mail script for Japanese notification also getting English Message. Please suggest
Message Key - Japanese
Message Key - English
Mail Script
(function runMailScript(current, template, email, email_action, event) {
var link = gs.getProperty('property.name');
var msg=gs.getMessage('Click Here For URL');
template.print('<a href="'+link+'">'+msg+'</a>');
})(current, template, email, email_action, event);
When I'm using above mail script for japanese notification also getting English Message. Please suggest
Regards,
Sruthi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 09:43 PM
Hi there,
Within mail script, you could consider applying getMessageLang().
gs.getMessageLang('message_key', 'language_id');
2021-07-01 Return a message in a specific language, gs.getMessageLang()
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 09:24 PM
Hi, why don't you try creating new message key and test?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 09:32 PM
I tried to test creating 2 separate message key for English and Japanese. Still for Japanese notification also getting English Message.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 09:43 PM
Hi there,
Within mail script, you could consider applying getMessageLang().
gs.getMessageLang('message_key', 'language_id');
2021-07-01 Return a message in a specific language, gs.getMessageLang()
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 10:20 PM
Hi Mark,
Thanks for the Reply. It is working Now.
I have created 2 notification one for English user and the other one for Japanese user. I have created 2 mail script one for English user and the other one for Japanese user. Is it possible to add both the English and Japanese message key in single mail script instead of creating 2 mail script.
Please find the below mail script. I have modified the script as you suggested.
Mail Script English
(function runMailScript(current, template, email, email_action, event) {
var link = gs.getProperty('property.name');
var msg=gs.getMessageLang('Click Here For URL','en');
template.print('<a href="'+link+'">'+msg+'</a>');
})(current, template, email, email_action, event);
Mail Script Japanese
(function runMailScript(current, template, email, email_action, event) {
var link = gs.getProperty('property.name');
var msg=gs.getMessageLang('Click Here For URL','ja');
template.print('<a href="'+link+'">'+msg+'</a>');
})(current, template, email, email_action, event);
s it possible to add both the English and Japanese message key in single mail script instead of creating 2 mail script. Please suggest
Regards,
Sruthi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 10:45 PM
"Is it possible to add both the English and Japanese message key in single mail script instead of creating 2 mail script."
Theoretically, yes you could do so. You could for example query for the language of the user you are sending the notification to, or using the language of the user who initiates the notification.
Issue though... when the notification is send by someone with English language to someone with different language. Or when the notification is send to multiple recipients and not all have the same language. For that you do need to have multiple notifications or triggering notifications scripted, through events, etc.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field