Notifications

51 views

Description

Description

Use following approach to get the translated text for a field from server script. This approach is applicable for any fields of type "Translated Text" or "Translated HTML".

Procedure

Execute 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 the above replace the placeholders with following:

<tablename> is the name of the table where the translated field exists.

<sysid> is the sys_id of the record

<fieldname> is name of the translated field.

 

The value in variable trans_text will be dependent on:

a) the current language selected for the user's current session.

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

 

Applicable Versions

All

Additional Information

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/localization/task/t_TranslateATranslatedTextField.html

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/localization/concept/c_AdministerTranslatedTextFields.html

Article Information

Last Updated:2019-08-02 20:41:47
Published:2019-05-28