Translation of email notification - gs.getMessage('${comments}')

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi guys,

I need your help please.

I configured the Incident email notification Incident commented for ESS for all the different languages based on the Caller User Language.

Now, I'm testing it and I can't find the reason why the name of the fields in the table generated by the script incident_comments is not getting translated:

find_real_file.png

This is the part of the code in the script incident_comments:

template.print('<p><font size="3" color="#666666" face="arial">' + gs.getMessage('${comments}') + '</font></p>');

Question is: is it possible to get the proper translation based on what defined in the sys_ui_message table using the function gs.getMessage? If not, what do I need to use for doing it?

This is the record in the sys_ui_message table I have:

find_real_file.png

Thanks a lot.

Cheers

Alberto

 

9 REPLIES 9

Mark Roethof
Tera Patron
Tera Patron

Hi there,

This is just about the "Additional comments" label itself, is that correct?

The sys_ui_message looks a bit odd. I've never seen/used a sys_ui_message like you are trying.

Looking at your question. The field names are stored in labels. Not in sys_ui_messages. Haven't tried myself, though you could try to add a sys_ui_message with key same as a field label, and then you're translated message. Maybe this will work fine for a notification.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Though actually thinking again... the notification will be generated thru the system. At that moment, I guess the base language is applied: English. So will a gs.getMessage actually work on a notification?

I don't think so. Also looking at one of our customer instances, all notifications are setup in 2 languages and based on the conditions for when to send, an English or Dutch mail will be generated (both hardcoded sentences and mail script which gets the translated values).

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

thanks a lot for your reply, checked in the sy_ui_message table, there is already the OOTB German translation for the label "Additional comments":

find_real_file.png

I have the same Email Notification setup like you mentioned, so when to run is based on the Caller Language:

find_real_file.png

So, as you said, gs.getMessage doesn't work properly because it's getting the system language (English) instead of German.

Do you know how to set the language to German directly in the notification email script so that gs.getMessage will get the German label? Or...do I need to use another way for populating the field names properly in German?

(function runMailScript(current, template, email, email_action, event) {
	template.print('<p><font size="3" color="#666666" face="arial"><strong>');
	template.print(gs.getMessage('Kommentare:'));
	template.print('</strong></font></p>');
	template.print('<p><font size="3" color="#666666" face="arial">' + gs.getMessage('${comments}') + '</font></p>');
})(current, template, email, email_action, event);

Thanks for your precious help.

Cheers

Alberto

Hmmm have to think about this one! It's a nice thought about what you are after and would be very efficient. 

What I see at customers, they have both English and Dutch notifications. Notifications which do also use mail scripts. Though... also those mail scripts are in English version and Dutch version. For example, header_dutch, header_english 😞

Obviously you could do a GlideRecord query to fetch the sys_ui_message in your language. It will work fine, though it feels a bit strange having to do this. 

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn