Issue
Use the following approach to get the translated text for a field from the server script. This approach is applicable for any fields of type "Translated Text" or "Translated HTML".
Procedure
Execute the following server script code to get the translated text:
// get translated text
var trans_text = '';
var gr = new GlideRecord("<tablename>");
if (gr.get("sys_id","<sysid>")) trans_text = gr.getDisplayValue('<fieldname>');
In this script, replace the placeholders with the following:
<tablename>
is the name of the table where the translated field exists.<sysid>
is the sys_id of the record<fieldname>
is the name of the translated field.
The value in variable trans_text
will be dependent on:
- the current language selected for the user's current session.
- if a corresponding record exists in the sys_translated_text table. If no translation record is found, the English version of the field's value will be returned.