Email Script Content Not Getting Translated with Dynamic Translation in Email Notifications

Rahuf Sayyad
Tera Contributor

Hi Community,

 

I've configured Dynamic Translation in my ServiceNow instance specifically for email notifications. When I use the "Request Translation" button, most of the email content is being translated as expected.

However, I'm facing an issue where any content that is rendered using email scripts is not being translated.

 

Example Scenario:

In the notification body, I'm using an email script to generate some content:

${mail_script:About_The_Request_Req_Survey_Req_Completed}

 

This hardcoded text stays in English, even though other parts of the email get translated properly.

 

What I've Tried:

  • Verified dynamic translation is enabled and working for other parts of the email.

What I'm Looking For:

  • Is there a way to include email script content in dynamic translation when using "Request Translation"?

  • Are there any best practices or workarounds to ensure the entire email, including email script output, is translatable?

Any guidance or experience on how to make email scripts compatible with dynamic translation would be greatly appreciated.

 

Thanks in advance!

 

Email Body:

RahufSayyad_3-1747406940022.png

 

English Email:

 

RahufSayyad_1-1747406635678.png

 

Translated Email:

RahufSayyad_2-1747406847195.png

 

1 ACCEPTED SOLUTION

John Gilmore
Giga Guru

Two thoughts on this, if the text returned by the request_greetings script is being properly translated and the text output by the About_* mail script isn't then you can likely look at how they are structured to determine what is different about them. Certain translation functions require you to use gs.getMessage or a similar method and configure the message. Not sure thats what is going on here but could be something like that is required.

You may also try something simpler like moving the body content of the notification into and email template and then use the template for the notification. Not sure that would resolve your issue but would take only a minute or two to test it.

View solution in original post

2 REPLIES 2

John Gilmore
Giga Guru

Two thoughts on this, if the text returned by the request_greetings script is being properly translated and the text output by the About_* mail script isn't then you can likely look at how they are structured to determine what is different about them. Certain translation functions require you to use gs.getMessage or a similar method and configure the message. Not sure thats what is going on here but could be something like that is required.

You may also try something simpler like moving the body content of the notification into and email template and then use the template for the notification. Not sure that would resolve your issue but would take only a minute or two to test it.

Rahuf Sayyad
Tera Contributor

✅Follow-up Explanation:

Hi @John Gilmore,

Thanks for the suggestion! I tried using gs.getMessage() in the email script, and it worked perfectly after one additional step.

For anyone else facing the same issue - here's what I did to get the translation working in notification email scripts:

  1. Wrap the text that needs to be translated using gs.getMessage('your_message_key') inside your email script.

    Example: var message = gs.getMessage('welcome_email_text');

  2. Create a new record in the sys_ui_message table with

    • Key: The exact text or message key used in gs.getMessage()

    • Language: The target language (e.g., fr for French)

    • Message: The translated text that should appear in the email

  3. After doing this, the notification renders the translated message correctly based on the recipient’s language.

Hope this helps anyone else trying to localize their notifications via email scripts!