What is "code" field in sys_ui_message table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 01:14 AM
I wanted to understand what is "code" field on the message table form??
What is the use of this?? when we use this??
Thanks in Advance
Utsav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 01:27 AM
Hi @Utsav JAISWAL ,
The “code” field in the sys_ui_message table in ServiceNow is used to store a unique key (also referred to as the message key) that identifies a localized UI message.
Purpose of the code Field:
• It acts as a message identifier that can be referenced in scripts or UI policies to display localized messages.
• It supports internationalization (i18n) by mapping the same code to different message texts based on the user’s language locale.
⸻
How It’s Used:
• You reference the code like this in your server/client script:
gs.getMessage('your_code_here')
or in a client script:
g_scratchpad.message = g_user.getMessage('your_code_here');
• ServiceNow will return the message text that corresponds to the code in the user’s language.
⸻
Example:
If you have a row in the sys_ui_message table like:
• Code: error.missing_field
• Message: This field is required.
Then in your script:
var message = gs.getMessage('error.missing_field');
// message = "This field is required."
If the same code is defined in another language (e.g., French), French users will automatically see the translated message instead.
Hit Helpful if this was helpful for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Do you have any source link to this information?
A unique key that identifies a localized UI message is stored in field Key [key], Code [code] is a different field.
Documentation reference: https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/localization/r...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Personally , i have never used this field in message table.
But by looking at the existing data , if feels like it can be used to store a name of system property type of values like "com.glide.sys.fencing.cross_scope_access.crossscopefeedback"
Best, would be to crosscheck the existing data to get an idea.