- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2026 04:52 AM
I am confused between getMessage() and getMessages() in ServiceNow.
Both are used to fetch localized messages from the System Message table, but I want to understand the exact difference and when to use each one.
Can someone briefly explain this with a simple example?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2026 09:11 PM
Hi @AzeemullahA ,
In ServiceNow, getMessage() retrieves a single localized message string, while getMessages() retrieves multiple localized messages at once. Use getMessage() when you only need one translation, and getMessages() when you want to fetch several translations in a single call for efficiency.
Key Differences
Feature getMessage() getMessages()
| Purpose | Fetches one localized message | Fetches multiple localized messages |
| Input | A single message key (string) | An array of message keys |
| Use Case | When you need just one message | When you need several messages at once (better performance) |
| Performance | Multiple calls can be inefficient | More efficient for bulk retrieval |
| Return Type | A single translated string | An object/dictionary of key-value pairs (key → translated string) |
Example 1: Using getMessage()
// Client Script
var msg = getMessage('hello_world');
alert(msg);
// Output: "hello_world"
Example 2: Using getMessages()
// Client Script
var msgs = getMessages(['hello_world', 'goodbye_world']);
alert(msgs['hello_world']); // "Hello World"
alert(msgs['goodbye_world']); // "Goodbye World"
------------------------------------------------------------------------------------------------------------------------------
If this helps you then mark it as helpful and accept as solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2026 09:11 PM
GlideSystem - getMessage(String messageID, Object args)
gs.getMessage() retrieves messages from the Messages (sys_ui_message) table based on the current user's language settings. In short, you can write language independent scripts provided the right messages are in the table. Consider the following script:
gs.addInfoMessage('Hello');No matter what, this will always print "Hello". Now, let's go to System UI> Messages and enter the following record:
Let's modify that script slightly to use the message we just created.
var msg = gs.getMessage('Hello');
gs.addInfoMessage(msg);var my_message = gs.getMessage("Abort adding action '{0}', same subflow can't be added twice in this subflow.", current.action.name);
alert(my_message);GlideSystem - getMessageS(String messageID, Object args)
Retrieves translated messages to display in the UI and escapes all ticks (').
If the specified message identifier (key) exists in the Message [sys_ui_message] table for the current language, the method returns the translated message. If the specified message identifier does not exist for the current language, the method returns the English version of the message. If the message identifier does not exist in the table, then it returns the message ID.
var my_message = '${gs.getMessageS("I love France")}';
alert(my_message);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
getMessage() also has a function available that provides the same functionality like the second parameter in gs.getMessage (server-side). It can be used this way:
getMessage("Msg: {0}").withValues(["Text"])
