Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to use gs.getMessage() to get the string translated?

hyperjam
Giga Contributor

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 ...

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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


View solution in original post

11 REPLIES 11

Vinicius Assis
Tera Expert

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/localization/task/t_TranslateAClientScriptMessage.html