GetMessage() is not translating to the language of the user who will receive the message

Weverton
Tera Contributor

Hi guys! I'm trying to use the preferred language of the user who opened the incident. In my test, I'm receiving the correct preferred language, "es" or "en", but the translation is not occurring as I expect, because it's not translating to the user's language but to my language. What am I doing wrong?

 

 

(function executeRule(current, previous /*null when async*/ ) {

    var incident = new GlideRecord("incident");
    incident.addQuery("problem_id", current.sys_id);
    incident.query();
    var msg = '';
    var closeNotes = '';

while (incident.next()) {
        if (incident.isValidRecord()) {
            var userLanguage = incident.caller_id.preferred_language;


            if (current.problem_state) {
                var state = current.getValue('problem_state');

                switch (state) {
                    case '1': // Analysis
                        msg = gs.getMessage('inc_status_change_analysis_by_pblm', userLanguage);
                        break;
                    default:
                        break;
                }

                if (msg) {
                    incident.comments.setJournalEntry(msg);
                }
            }

 

 

 message.pngmessage.png

1 REPLY 1

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

You could use getMessageLang() for this. See this article that I wrote a few years ago:
- 2021-07-01 - Article - Return a message in a specific language, gs.getMessageLang()

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn