- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 05:35 AM
var ret = ' ';
....
....
if(counter_app == 0){
switch(counter_level){
case 0:
ret += "First level of approval "; // <------ how to get such string translated?
break;
....
}
if (when.indexOf('always') == -1)
ret += '\(Depends on selected options)\: '; <--------- how to get such string translated too?
else ...
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 05:41 AM
Sorry Anna,
I thought you were doing a client script.
For server side scripts (business rules, UI actions, etc) there's no Messages field and you use the gs.getMessage() call.
For best results, go to System UI> Messages and create your translated messages. For example,
key=first_level_of_approval, Message=First level of approval
Now in your script...
ret += gs.getMessage('first_level_of_approval');
This may also be helpful: gs.getMessage() - The Second Parameter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 05:39 AM
Hi Anna,
For best results, go to System UI> Messages and create your translated messages. For example,
key=first_level_of_approval, Message=First level of approval
Then, in the client script, add this to the Messages field
first_level_of_approval
This tells the client script to retrieve the translated message BEFORE it needs it for better performance.
Now in your script...
ret += getMessage('first_level_of_approval');
Lather, rinse, repeat for other messages you want to translate.
FYI - the server counterpart is gs.getMessage()
Client Scripts - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2017 06:26 AM
Hey Chuck, what it the variant to use on the service portal? Because getMessage() is not supported on the portal and does not return the translation... by design... But there should be some way to translate messages right?
Here is the thread I created

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2017 06:44 AM
You can do this in the server script and set information in the data object that is available to the client and HTML.
Example:
data.more_info_reqd = gs.getMessage('More information required');
FWIW, I tend to load up my messages at the top of the server script for readability rather than embed them inline

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2018 02:06 AM
Hi Chuck,
I have a same requirement as above:
I have created messages in system localization for all translations(screen shot attached) and using those messages through getMessage() method in catalog client scripts(screen shot attached).
Can you please help me figure out the solution