Multilingual for a Group Notifications – Watch_lis... - ServiceNow Community
Haithem D_
Giga Expert

Hi all,

In some cases we could have in the same group members speak different languages, like assignment_group or watch_list or ….

In this section we will handle the notification sent to watch_list and the caller_id when a comment has been added, for users with English and German Languages.

Please below the steps as described below:

  • Create new update set “Multilingual Notification” and make it as current.
  • Install plugins:
    1. I18N: Internationalization
    2. i18 for german language.
  • Select 4 or 5 users and set the languages for them (2English, 2 German).
  • Create 2 notifications one for English and one for German.
  • Create 2 Events
  • Create one business rule to trigger those events.

 

Details,

  • First we Create 2 events as below:

Filter navigation, System Policy à Events à Registy à new

Name: notification.german, table: Inciden

find_real_file.png

Again the same thing for English notification:

Name: notification.english, table: Incident

find_real_file.png

 

  • Second we create 2 notifications as below:

System Notification à Email à Notifications à New

Name: Notification DE, table: incident, when to send: event is fired, event name: notification.german, who will receive: Event param 1 and what it will contain you can type what you want.

find_real_file.png

 

find_real_file.png

The same for the English notification

Name: Notification EN, table: incident, when to send: event is fired, event name: notification.english, who will receive: Event param 1 and what it will contain you can type what you want.

find_real_file.png

 

find_real_file.png

  • Finally we create the business rule in the incident table to trigger those events notifications as below:

find_real_file.png

Below the script:

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

    // 2 array to locate german, english users

                  var ids_german = [];

                  var ids_english = [];

                  var list = current.watch_list.toString();

                  var array = list.split(",");

  for (var i=0; i < array.length; i++)

{

                  gs.log("languages: " + array[i]);

                  var user = new GlideRecord('sys_user');

                  user.addQuery('sys_id',array[i]);

                  user.query();

                  while(user.next())

                                    {

                                                      if(user.preferred_language!='de')

                                                                        {

                                                                                          ids_english.push(user.sys_id.toString());

                                                                        }

                                                      if(user.preferred_language=='de')

                                                                        {

                                                                                          ids_german.push(user.sys_id.toString());

                                                                       

                                                                        }

                                    }

}

   if(current.caller_id.preferred_language=='de')

                                    {

                                                      gs.log("German");

                                                      ids_german.push(current.caller_id.toString());

                                    }

                  if(current.caller_id.preferred_language!='de')

                                    {

                                                      ids_english.push(current.caller_id.toString());

                                                      gs.log("English");

                                    }

   gs.eventQueue('notification.english',current,ids_english,current.sys_id);

   gs.eventQueue('notification.german',current,ids_german,current.sys_id);

})(current, previous);
Comments
Vivi Brasil
Kilo Sage

Hi Haithem D., awesome article, greatly appreciate the information! This is the best solution in regards to Multilingual for a Group Notifications! 😃

We have tried before another approach with events, but as we didn't use an array to record the recipients per language, we faced some issues on that, because it fired one notification / one single email for each recipient, so, in some cases with Assignment groups which contain many members, the Activity Stream with the "Sent/Received Emails" showed a lot of individual emails (exceeding the number of activity stream entries), in addition, in a particular case the customer mail server has identified those single emails as spam (as a Group not intended to be used as Assignment group was accidentally used for it, generating a lot of single emails). So, this solution you proposed here is really great as you have one email with all the recipients which use the same language, and it is a simple solution to implement, with the steps above you described so well!

I just wanted to point out that the Language field on User table [sys_user.preferred_language] is not updated if the user sets his language through the Profile (the Profile only creates or updates his Language on sys_user_preference table). So, in our implementation, we have also created a Business Rule to sync the User Preference's Language (basically every time a record is inserted or updated in the sys_user_preference in regards to language, it is replicated to the sys_user table).

Thank you so much!
Viviane

Haithem D_
Giga Expert

Hi Vibrasil,

 

I'm glad that you find this article helpful, and thank you for the tipps (business rule to sync the User Preference's Language).

 

Best Regards,
Haithem Dadi.

Version history
Last update:
‎02-04-2020 05:24 AM
Updated by: