Issue
The getMessage() function is not returning expected translated text when client script is execute in Portal or Workspace context.
The first time the function is called it is returning the English text (key value).
The second time the function is called it is returning the expected translated text (based on the current selected language)
getMessage() can be used to display text in different places the platform. Sometimes the translations for the text found inside of getMessage() does not get translated as expected.
EXAMPLE:
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == '1'){
alert(getMessage('Test : English version'));
}
}
Release
All releases.
Cause
By design, Service Portal and Mobile client scripting environments do not support synchronous use of getMessage(). However, a getMessage() with a callback function can be used to translate text from getMessage(). To see an example of how the translation can be done, see the solution section next.
Resolution
getMessage('Test : English version', function(msg){alert(msg);});