translations for onChange catalog client script through getmessage() method not working

poojitha bn
Giga Expert

Hi Team,

I have a requirement as below.

Sub category field is dependent of category field so I created onChange Catalog client script to achieve this.

Now I wanted to translate sub category options to other languages based of loggedin user language.

I have tried below option but not working.

Created translations in System Localization > Messages.

find_real_file.png

Using it in catalog client script like below:

find_real_file.png

Please help me if anybody know how to correct

1 ACCEPTED SOLUTION

poojitha bn
Giga Expert

I found the solution for the above issue:

code working for me:

else if(newValue == "Employee Data Change"){
getMessage('Employee data change', function(msg){
g_form.addOption('u_category_2', msg , msg );
});
}

View solution in original post

4 REPLIES 4

SatheeshKumar
Kilo Sage
Add the message key in messages field of your client script.. Then it will work as expected. Are you using this in portal or in native ui?

poojitha bn
Giga Expert

Hi Satheesh,

 

Thanks for the reply. Do u mean to say as below(tried this but didn't worked)

find_real_file.png

Can you please brief me more details.

 

No.

 it seems you are not utilising the "Messages"  field in client script form.

Edit form layout and add Messages multiline text in your form first.

Then fill that messages field with key value used in translation.

then use getMessage in your code.

if you follow the above steps your issue will be resolved.

 

Refer the below link for more details

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

 

find_real_file.png

Thanks,

satheesh

poojitha bn
Giga Expert

I found the solution for the above issue:

code working for me:

else if(newValue == "Employee Data Change"){
getMessage('Employee data change', function(msg){
g_form.addOption('u_category_2', msg , msg );
});
}