GlideSystem - getMessage(String messageID, Object args)

Retrieves translated messages to display in the UI.

If the specified string exists in the database for the current language, then the translated message is returned. If the specified string does not exist for the current language, then the English version of the string is returned. If the string does not exist at all in the database, then the ID itself is returned.

If the UI message has a tick ('), there may be issues with the message in the script; to escape the ticks ('), use getMessageS(String, Object).

Table 1. Parameters
Name Type Description
MessageID String The ID of the message.
args Object (Optional) a list of strings or other values defined by java.text.MessageFormat, which allows you to produce language-neutral messages for display to users.
Table 2. Returns
Type Description
String The UI message

Scoped equivalent

To use the getMessage() method in a scoped application, use the corresponding scoped method: Scoped GlideSystem - getMessage(String id, Object args).

var my_message = '${gs.getMessage("This is a message.")}'; 
alert(my_message);

Using the optional parameter:

gs.getMessage('"{0}" is not a Client Callable Script Include','BAR’);

Output:

"BAR" is not a Client Callable Script Include