Translation of drop down values which are added from Catalog Client script

sk59
Tera Expert

Hi,

we were able to translate all the drop down values which are added  from Quetion choices or choices but the choices which are added from Catalog Client script using addOptions how to translate those?

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

store the choice values translation in messages table and use that

g_form.addOption('field', getMessage('choice value'),getMessage('choice value'));

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

I have 50 such choices which are added via addOption. Do I need to add this g_form.addOption('field', getMessage('choice value'),getMessage('choice value')); in the same catalog client script for all the 50 choices?

 

I have to translate these for almost 15 languages so do i need to do this addoption for 15 languages?

Hi,

For 1 choice if you want 2 languages then 2 entries here

So if total 50 such choices then 100 entries into messages table

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Can you please help with the script.

This is the one which is been used currently to add choices. How to include translations script

function onChange(control, oldValue, newValue, isLoading) {
g_form.clearOptions('subcategory');
g_form.addOption('subcategory', '', '-- None --', 0);
g_form.setReadOnly('subcategory', false);
g_form.setMandatory('subcategory', true);

if (isLoading || !newValue) return;

var options = getOptions(newValue);

if (options && options.length) {
options.forEach(function (option) {
g_form.addOption('subcategory', option.value, option.label,
option.sequence);
});

} else {
g_form.setMandatory('subcategory', false);
g_form.setReadOnly('subcategory', true);
}

function getOptions(category) {
return {
hardware: [
{
label: 'AS400',
value: 'as400',
]
}[category];