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

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

Because you are using multiple Messages, just add them all to the messages field, seperated by an enter. Working example of how this works:

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