- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 11:55 PM
Hello All,
Can anyone please help me on the below requirement. I have written a business rule to set the set short description of the catalog item based on the few variables value.
In English version the short description is showing correctly but how to set this short description to japan langauge the japansese user will use this.
Can anyone please help how to achieve.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 02:57 AM
Hello @Mansi roy
Here is the updated script:
var shdesc = '';
var roles = [];
var entitlements = [];
var role_mrvs = JSON.parse(current.variables.required_roles);
var entitlement_mrvs = JSON.parse(current.variables.required_entitlement);
if (role_mrvs != '') {
for (var i = 0; i < role_mrvs.length; i++) {
var gr_role = new GlideRecord('u_oim_roles_list_new');
if (gr_role.get(role_mrvs[i].role)) {
roles.push(gr_role.u_role_name);
}
}
shdesc = gs.getMessage('For {0}: {1}: {2}', [
current.variables.user_id.getDisplayValue(),
current.variables.request_type.getDisplayValue(),
roles.toString()
]);
}
if (entitlement_mrvs != '') {
for (var j = 0; j < entitlement_mrvs.length; j++) {
var gr_entitlement = new GlideRecord('u_oim_single_entitelments');
if (gr_entitlement.get(entitlement_mrvs[j].entitlement_name)) {
entitlements.push(gr_entitlement.u_entitlementname);
}
}
shdesc = gs.getMessage('For {0}: {1}: {2}', [
current.variables.user_id.getDisplayValue(),
current.variables.request_type.getDisplayValue(),
entitlements.toString()
]);
}
// Update the short description
current.short_description = shdesc;
current.update();
- gs.getMessage() supports translation by replacing static strings with localized versions.
- In this case, phrases like 'For {0}: {1}: {2}' will be translated if corresponding keys exist in the system.
- Placeholders ({0}, {1}, {2}) are dynamically replaced with the provided values in the array.
- Add translations for 'For {0}: {1}: {2}' into your system's Messages table (sys_ui_message), with keys and their corresponding translations (e.g., Japanese).
Adding Translation Keys
- Navigate to System UI > Messages.
- Create a new message entry:
- Key: For {0}: {1}: {2}
- Message (Japanese translation): 対象 {0}: {1}: {2}.
- Repeat for any other keys or phrases used.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 12:27 AM
Hello @Mansi roy
- You need to use the gs.getMessage() method in your script. Additionally, create a new record in the sys_ui_message table to store the translated messages.
- For more information on how to use the sys_ui_message table, please refer to this link: Message table
- Could you please share the script you're using to set the description field? This will help in providing more specific guidance.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 02:51 AM
Hello Juhi,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 02:51 AM
Hello @Mansi roy
Do check this thread which will be helful to you.
Solved: How to achieve Dynamic Translation on message. - ServiceNow Community
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.