- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 12:08 PM
Hi,
I'm trying to manage a system with users that speak multiple languages on my personal instance. I am currently employing the method of creating multiple versions of the same message in the sys_ui_message table. However, when email notifications are sent out, they are still in english. I've impersonated someone with a different language preference and tested the function in background script and it works there.
I've tried querying via the recipients, but I can't seem to access recipients.
var user = new GlideRecord('sys_user');
user.addQuery('email', email_action.recipient);
user.query();
if(user.next()){
var gr = new GlideRecord('sys_ui_message');
gr.addQuery('key', 'An incident has been opened on your behalf.');
gr.addQuery('language',user.preferred_language);
gr.query();
if(gr.next()){
gs.print(gr.message);
}
}
}
I could create separate translated notifications for each language but the dynamic aspect of using the prepared messages is very appealing.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 01:24 PM
If all you need to get is the language of the recipient for the Incident opened for me Notification, you should be able to dot-walk through the caller_id field instead of doing a lookup on the user table from the recipient email address: current.caller_id.preferred_language that should eliminate the need to look up the user since you can get to it from the caller_id field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 12:34 PM
Without knowing where the script you gave us is located, it is difficult for us to try and replicate this.
My experience is that notifications need to be defined so that the translations are contained within the notification record and not generated when they are being delivered. Typically notifications can go to multiple recipients and this may be why what you are doing is unsuccessful (there is no way to determine which language to use in the generated notification). If you have one recipient, you may find success but I have not attempted to do so from a reference field on the triggering record.
Let us know how your solution is currently built so we can try to replicate and offer possible solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 01:07 PM
I am currently modifying the OOB 'incident_has_been_opened' mail script meant for the OOB 'Incident opened for me' notification. I've activated the internalization plugin to the instance so I am able set the preferred_language field of users to something not English. I've impersonated the users and have tested gs.getMessage('incident_has_been_opened') in background script to retrieve the message in the language of the user.
In 'incident_has_been_opened', I tried simply putting gs.getMessage('incident_has_been_opened') but the language stays English when it sends to the caller. Is there a way that we can force a certain email to reference the user language instead of the system language?
I am currently querying in the mail script to get the preferred language of the user and have the message called by querying with key and language. However, i am having trouble of getting recipients of the outbound email.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 01:24 PM
If all you need to get is the language of the recipient for the Incident opened for me Notification, you should be able to dot-walk through the caller_id field instead of doing a lookup on the user table from the recipient email address: current.caller_id.preferred_language that should eliminate the need to look up the user since you can get to it from the caller_id field.