How to translate field error message based on user's language?

Buddy 1
Tera Contributor

Hi,

There is a field validation and it will show error message ,if not validated properly.

Now the error message should be shown in different languages based on user's language

 

How to achieve this?

Thanks in advance!

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Buddy 1 

do this and it will work based on user's language

getMessage("YOUR_MESSAGE_KEY", function(msgString) {
                g_form.showFieldMsg('field_name', msgString, 'error');
            });

 

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

View solution in original post

5 REPLIES 5

MahaAgineo
Tera Guru

Hi @Buddy 1 ,

to solve this Problem, you need to do the following:

  • Create the message translation in the sys_ui_message table
  • Create Records with languages you need
  • Add the following code in your script to get the translated error according to the user language: gs.getMessage('your error message')

If my answer solved your issue, please mark my answer as Correct & Helpful 😉

Best Regards

Maha

Hi @MahaAgineo ,

How can i achieve this with client script ?

 

Thanks in advance!

Hi @Buddy 1,

you have two options:

  • you can either create display BR and put the error message in the g_Scratchpad
  • you can use GlideAjax and return as a response the translation

In both of them, you will use: gs.getMessage() to get the translated text

Ankur Bawiskar
Tera Patron
Tera Patron

@Buddy 1 

do this and it will work based on user's language

getMessage("YOUR_MESSAGE_KEY", function(msgString) {
                g_form.showFieldMsg('field_name', msgString, 'error');
            });

 

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