The CreatorCon Call for Content is officially open! Get started here.

Client Script getMessage no found translation the first time

Nicolas Leduc
Tera Contributor

Hi all !

I put the code below in a variable set catalog client script.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var choice = g_form.getValue('u_end_of_service');
var message = '';

switch(choice) {
case 'Resignation by employee':
message = getMessage("Please attach the following documents :"); 
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
message = "- " + getMessage("Resignation letter");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
message = "- " + getMessage("Agreement of the P&O Director");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
break;
case 'End of a fixed-term contract or a replacement contract':
message = getMessage("Please attach the following documents :");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
message = "- " + getMessage("Excel list");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
break;
case 'Decease of an employee':
message = getMessage("Please attach a copy of the death notice as an attachment");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
break;
case 'Pension':
message = getMessage("Please attach the agreement of the Federal Pension Service as an annex");
g_form.showFieldMsg('u_end_of_service', message, 'info', false);
break;
default:
message = '';
g_form.hideFieldMsg('u_end_of_service');
break;
}
}

 

In english, it's functionnal, but when i try to use another language, it's not functionnal at the first time.

The translation is in System Localization >Messages menu.

When the form load, i select my choice (Resignation by employee in french for exemple) and the text is in english.

If i select another choice, the text is also in english.

But, if i select Resignation by employee again, the text is in french. I need to see a second time the message to get the translation...

How can i get it the first time ?

 

Thank you for your answer 🙂

1 ACCEPTED SOLUTION

See this example of a working Catalog Client Script with getMessage:

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

6 REPLIES 6

AbhishekGardade
Giga Sage

Remove (line 2,3,4 )this part and try:

if (isLoading || newValue == '') { return; }

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade

Hi Abhishek, 

I try this solution, and the translation is found the second time like every time.

But thanks for this test 🙂

Leduc Nicolas

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Are you applying the Messages field on the Catalog Client Scripts? Out-of-the-box this field is not on the form lay-out, you can just add it (it's an excisting field).

This should solve your issue. We encountered this before also with our Dutch language.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

What do you mean by appllying the messages field on the catalog client script ?

I just create a variable set and add a client script in it so no i suppose 

Thanks for your answer,

Leduc Nicolas