- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 05:10 AM
Hi,
I have written script include to translate the text value of field catalog item because this field not translating non-english language. Then i passed the value to notification email script. This script correctly translating catalog item non - english language but if it is english - its show undefined. because there is no record for English language into translated_Text table. pls let me know any correction required in the script to display english language also with out any error:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:19 AM
Hi @BanuMahalakshmi ,
If the translation for your field not exist just return the value of the field. Try with this:
gettranslationMessage: function(fieldname, language,documentkey) {
var res;
gs.log("loop running script");
var translate = new GlideRecord('sys_translated_text');
translate.addEncodedQuery('fieldname=' + fieldname + '^language=' + language + '^documentkey=' + documentkey);
translate.query();
if (translate.next()) {
res = translate.value;
} else {
res = fieldname // I think the fieldname is the text you want to translate or documentkey you now which is the correct.
}
return res;
},
Hope that help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 05:36 AM
Did you explore dynamic translation on email notifications starting from Tokyo?
How to setup dynamic translation on email notifications for first time?
Also check this
Multilingual email notifications
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:19 AM
Hi @BanuMahalakshmi ,
If the translation for your field not exist just return the value of the field. Try with this:
gettranslationMessage: function(fieldname, language,documentkey) {
var res;
gs.log("loop running script");
var translate = new GlideRecord('sys_translated_text');
translate.addEncodedQuery('fieldname=' + fieldname + '^language=' + language + '^documentkey=' + documentkey);
translate.query();
if (translate.next()) {
res = translate.value;
} else {
res = fieldname // I think the fieldname is the text you want to translate or documentkey you now which is the correct.
}
return res;
},
Hope that help you.