Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Push Message not translating

Diogo Almeida1
Tera Expert

Hello all,

 

As the title says I am trying to localize Push notifications using gs.getMessage(). I have created the messages both in English and Portuguese in System Localization > Messages. Then created the following email script for the request completed Push notification message:

 

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    var msgArray = [];

    // Put the dynamic parts of the message in an array
    msgArray.push(current.number);
	msgArray.push(current.short_description);
    
    template.print(gs.getMessage('request_completed', msgArray));

})(current, template, email, email_action, event);

 

 Then I call it in System Notifications > Push > Push Messages: ${mail_script:request_completed}

 

However, when triggering the message for a test user that has the language in preferences set as Portuguese, the message is not being sent in Portuguese. Am I missing something?

 

Screenshot.jpg

 

Best regards,

Diogo

1 ACCEPTED SOLUTION

Javier Dom_nech
ServiceNow Employee
ServiceNow Employee

Hi Diego,

I was trying to achieve a similar or pretty much the same functionality. Based on the info at https://www.servicenow.com/community/international-localization/emails-in-other-languages-easy-to-co... I finally ended up using gs.getMessageLang() function instead and setting the user language depending on the recipient of the language (not dynamically, unfortunately).
I hope it helps!

View solution in original post

2 REPLIES 2

Javier Dom_nech
ServiceNow Employee
ServiceNow Employee

Hi Diego,

I was trying to achieve a similar or pretty much the same functionality. Based on the info at https://www.servicenow.com/community/international-localization/emails-in-other-languages-easy-to-co... I finally ended up using gs.getMessageLang() function instead and setting the user language depending on the recipient of the language (not dynamically, unfortunately).
I hope it helps!

nayanawadhiya1
Kilo Sage

Hello Diego,

 

Does your UI message contains parameter like below - 

key = 'im_notification_msg'
message = 'Message sent to {0} regarding {1}';