UI Page issue

SandeepKSingh
Kilo Sage

 

Question:

I have been tasked with localizing static error messages in ServiceNow to support multiple languages. Instead of using hardcoded strings for error messages, how to implement a solution to fetch the messages from a language-sensitive resource file.

gel('error_msg').innerHTML = "End date should not be empty"
1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage
Giga Sage

Hello @SandeepKSingh 

 

The static error messages should be localized to support multiple languages. Use ServiceNow’s g_i18n.getMessage() method to fetch messages stored in a language-sensitive resource file instead of hardcoded strings.

Example:

gel('error_msg').innerHTML = g_i18n.getMessage("Contract End date should not be empty, Please select a contract's End date.");

To add these messages, navigate to System UI > Messages in ServiceNow, and create entries for each of the required strings (e.g., "Contract start date should not be empty, Please select a contract's start date.").
More Details :- https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/i18N...

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hello @SandeepKSingh 

 

The static error messages should be localized to support multiple languages. Use ServiceNow’s g_i18n.getMessage() method to fetch messages stored in a language-sensitive resource file instead of hardcoded strings.

Example:

gel('error_msg').innerHTML = g_i18n.getMessage("Contract End date should not be empty, Please select a contract's End date.");

To add these messages, navigate to System UI > Messages in ServiceNow, and create entries for each of the required strings (e.g., "Contract start date should not be empty, Please select a contract's start date.").
More Details :- https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/i18N...

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

SandeepKSingh
Kilo Sage

This worked thanks 🙂