Notification Static Translation and printing text in Email Scripts does not together

Johannes Grosb_
Tera Contributor

Hi Community,

 

We are using Static Translation of Notification to translate outgoing emails into multiple languages.

In the Notifications we would like to use Email Script to Print dynamic text based on certain criteria's. This message is always printed in the default language, and not translated. Even using gs.getMessage() does not work (guessing because the way of how Static Translation works, kicking in after the outgoing email is created).

 

What alternatives are you using? What is best practice?

 

Example of printing text in Email Script

if (current.opened_by == current.contact) {
        template.print(gs.getMessage("We received your case and it is created in our tracking system. Please find below details of your case:"));
    } else if (current.opened_by == current.partner_contact && current.partner_contact){
		template.print(current.partner_contact.getDisplayValue() + " " + gs.getMessage("have created a case on your behalf. Please find below details of your case:"));
	} 
	else {
        template.print(gs.getMessage("We have created a case on your behalf. Please find below details of your case:"));
    }

 

I've considered:

  1. Splitting into multiple Notifications. This would generate a lot of Notifications (and translated version) with almost the same content, increasing the maintain burden.
  2. Creating translated versions of the Email Script, which also increase the maintain burden. But less than #1. 
  3. Don't use Email script to Print text. This would lower the clarity of the message.

 

Looking forward to read your good ideas.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Johannes Grosb_ 

yes you can create notifications in respective languages and use the correct one based on recipient.

Do you have the message stored in Messages table for the other language?

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

Hi Ankur

I have a Notification "Case opened for customer", which contains a Mail script "${mail_script:case.opened.on.behalf}" that Prints text:

 

template.print(gs.getMessage("We have created a case on your behalf. Please find below details of your case:"));

 

Message exists:

JohannesGrosb__1-1748434316855.png

But not translated:

JohannesGrosb__2-1748434481254.png

 


Translated Notifications:

JohannesGrosb__0-1748430600974.png

 

@Johannes Grosb_ 

then it should work fine

check this

Return a message in a specific language, gs.getMessageLang()

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

Johannes Grosb_
Tera Contributor

Got confirm from ServiceNow support that printing messages in email script only "works" together with Static Translation if you use the gs.getMessageLang(). Support has submitted an enhancement request for the documentation.

 

However this goes against the idea of Static Translation. If you were able to specify the language in the gs.getMessage() call, you would not need Static Translation.

The idea of Static Translation is to translate into the receiver preferred language, which A) can be different for different receivers. B) The receivers are first defined, after the message has been generated.

 

In short: If you use Email Script to Print and utilize Static Translation, you need an Email Script per language.