Translation – Messages

If your system is going to be used in multiple languages you might need to think twice before you hard code any message for your backend users or Service portal users.Hard coded messages don’t get translated automatically when a user changes languages, in this case what you need to do is to add the message that you want to display on sys_ui_message table which contains your original message as well as the translations for informational messages, confirmation messages, error messages, and other types of system messages.

ServiceNow checks this table for translation when a client script contains a getMessage or a server script contains gs.getMessage call.

The main fields for this table are:
Application: name of the application this message appears in.
Key: internal unique identifier of this message.
Language: language the message is translated into.
Message: translated text that users see.

Here is example:

// Hard coded message
gs.addInfoMessage('Please select the right service for this case');
//gs.getMessage() is going to call value for escalation_msg key, the value displays depend on user's language

Navigate to System Localization > Messages and then  create message for escalation_msg key in both English and French

When the code above triggers, it prints 2 messages in English

When user changes language to French

Hard coded message displays in English while the other one displays in French

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s