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

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...

View solution in original post

2 REPLIES 2

Ravi Gaurav
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...

SandeepKSingh
Kilo Sage

This worked thanks 🙂