Translation Issue

mouradhadj-
Tera Contributor

Hi,

I'm having trouble translating a message inside a Business Rule. I used gs.getMessage() along with the sys_ui_message table to store the translations, but the message is still not being translated in french.

this is my BR: 

 var ritmGrp = new GlideRecord('sc_req_item');
    ritmGrp.addQuery('sys_id', current.parent);
    ritmGrp.query();
    if (ritmGrp.next()) {
      var reqMessage = gs.getMessage(
            "Your request is waiting for approval by '{0}'",
            [' ' + current.assignment_group.name + ' ' + ' (' + current.assignment_group.u_short_description + ')']
        );
        ritmGrp.comments.setJournalEntry(reqMessage);


did some one know why ?

Thankx!!!!!
10 REPLIES 10

I tried your script : 

 var ritmGrp = new GlideRecord('sc_req_item');
    ritmGrp.addQuery('sys_id', current.parent);
    ritmGrp.query();
    if (ritmGrp.next()) {

        // get the language of logged in user and then use it in below line
        var myUserObject = gs.getUser();
        var lang = myUserObject.getLanguage();

        var reqMessage = gs.getMessageLang(
            "Your request is waiting for approval by '{0}'", lang,
            [' ' + current.assignment_group.name + ' ' + ' (' + current.assignment_group.u_short_description + ')']
        );
        ritmGrp.comments.setJournalEntry(reqMessage);
        ritmGrp.update();
    }

but still no translation 

@mouradhadj- 

you are running the script in the correct user's session whose language is France?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes !!

 

Hi Ankur,

I noticed something strange with the Business Rule. When I manually force the language to French (lang = 'fr'), the translation works correctly. However, by default, it doesn't apply the expected translation.

It seems like the system is not picking up the correct language setting automatically. Do you have any idea why this might be happening?

Thanks in advance for your help!

Best regards,

BR: 

(function executeRule(current, previous /*null when async*/ ) {
    var ritmGrp = new GlideRecord('sc_req_item');
    ritmGrp.addQuery('sys_id', current.parent);
    ritmGrp.query();
    if (ritmGrp.next()) {





        // get the language of logged in user and then use it in below line
        // var myUserObject = gs.getUser();

        var lang = gs.getSession().getLanguage();
        //lang = "fr";

        gs.info("la langue actuelle ==== " + lang);
        var reqMessage = gs.getMessageLang(
            "Your request is waiting for approval by '{0}'", lang,
            [' ' + current.assignment_group.name + ' ' + ' (' + current.assignment_group.u_short_description + ')']
        );
        ritmGrp.comments.setJournalEntry(reqMessage);
        ritmGrp.update();
    }

    /*

        var ritmGrp = new GlideRecord('sc_req_item');
        ritmGrp.addQuery('sys_id', current.parent);
        ritmGrp.query();
        if (ritmGrp.next()) {
            var myUserObject = gs.getUser();
            var lang = myUserObject.getLanguage();

            var reqMessage = gs.getMessageLang(
                "Your request is waiting for approval by '{0}'", lang,
                [' ' + current.assignment_group.name + ' ' + ' (' + current.assignment_group.u_short_description + ')']
            );

            ritmGrp.comments.setJournalEntry(reqMessage);

            // ritmGrp.comments = reqMessage + current.assignment_group.name + '(' + current.assignment_group.u_short_description + ')' ;
            ritmGrp.update();
        }
    */
})(current, previous);

@mouradhadj- 

Thank you for marking my response as helpful.

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