Translation - Alert Messages

kali
Tera Contributor

Hi All,

I am using alert message in the onsubmit client script but when i am created a record in the message table the value is not getting translated when using getMessage() , please help me how we can translate it 

Thanks in advance

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@kali 

this worked for me

it should work for you as well

function onLoad() {
    //Type appropriate comment here, and begin script below
    getMessage("This is my alert", function(msgString) {
        alert(msgString);
    });

}

58.png56.png

Output

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron

Hi @kali 

 

https://www.servicenow.com/community/itsm-forum/translating-the-alert-message-in-catalog-client-scri...

https://www.servicenow.com/community/developer-forum/translate-prompt-and-alert-message-triggered-in...

 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron

@kali 

this worked for me

it should work for you as well

function onLoad() {
    //Type appropriate comment here, and begin script below
    getMessage("This is my alert", function(msgString) {
        alert(msgString);
    });

}

58.png56.png

Output

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Ankur Bawiskar - Thanks it is working now

Tanushree Maiti
Tera Patron

Hi @kali 

 

Refer : Client Script 'Messages' and System UI > Messages

If this script is running inside the Service Portal or Workspace environments, the standard synchronous getMessage('key') syntax often returns the key instead of the translated value on the first try.

 

Refer: KB0696905 client script function getMessage() does not return expected translated text on Service Po... 

 

Resolution

This is a sample code that would work with the Example given in the Symptoms section of this article. Replace the "alert(getMessage('Test : English version'))" by the following:
getMessage('Test : English version', function(msg){alert(msg);});
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti