- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:26 PM
Get the label information of the dictionary record with the script below
I am localizing to a language other than English, but the values I get are in English.
Is there a way to get it in localized language?
var dic_rec = new GlideRecord("sys_dictionary");
dic_rec.addQuery("name", table_name);
dic_rec.query();
dic_rec.next();
gs.info(dic_rec.getDisplayValue("column_label") );
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:28 PM
Hi @bonsai ,
an write a script include to get the choice labels in specified language and use that.
Example:
var ChoiceHelper2 = Class.create(); ChoiceHelper2.prototype = { initialize: function() { }, getChoice: function(table, value, lang) { var grChoice = new GlideRecord('sys_choice'); grChoice.addQuery('name', table); grChoice.addQuery('value', value); grChoice.addQuery('language', lang); grChoice.query(); if (grChoice.next()) { return grChoice.label; } }, type: 'ChoiceHelper2' };
Test:
var choiceHelper = new ChoiceHelper2(); var label = choiceHelper.getChoice('incident', 'request', 'ja'); gs.info(label);
Result:
*** Script: 要求
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:28 PM
Hi @bonsai ,
an write a script include to get the choice labels in specified language and use that.
Example:
var ChoiceHelper2 = Class.create(); ChoiceHelper2.prototype = { initialize: function() { }, getChoice: function(table, value, lang) { var grChoice = new GlideRecord('sys_choice'); grChoice.addQuery('name', table); grChoice.addQuery('value', value); grChoice.addQuery('language', lang); grChoice.query(); if (grChoice.next()) { return grChoice.label; } }, type: 'ChoiceHelper2' };
Test:
var choiceHelper = new ChoiceHelper2(); var label = choiceHelper.getChoice('incident', 'request', 'ja'); gs.info(label);
Result:
*** Script: 要求
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 06:38 PM
Hi @bonsai,
If you have activated another language, you should be able to translate it without writing a script.
Which field/variable are you trying to translate?
Cheers