- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 07:08 AM
New to Jelly Scripting and would really appreciate help!
In my cart layout, I have added a new Widget Macro to Item Ordering Widget to display a custom field in my catalog item table called Delivery Standard. The script below is working (with help from SN). I need the label of this field to display based on the user's language.
When I created the new field, I edited the label properties and added French so that when a French user logs in, they see "Norme de livraison" for the field.
How do I refer to this field label below, if I don't want to hardcode the French and English label values?
Conversely, if I had to get the current user's language preference and write code to check that first and then display the html accordingly, how do I get the current user's language preference (ie. I can write a g:evaluate, but what do I put in my set to pass to my evaluate)?
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_id" value="${jvar_cat_item.getID();}" />
<g:evaluate var="jvar_delivery_standard" jelly="true" expression="
var itemGr = new GlideRecord('sc_cat_item');
itemGr.get(jelly.jvar_id);
itemGr.u_delivery_standard;
" />
<j:if test="${jvar_delivery_standard > 0}">
<tr>
<td id="sc_delivery_time_label_cell"><strong>Delivery Standard</strong></td>
<td id="sc_delivery_time_cell">${jvar_delivery_standard}</td>
</tr>
</j:if>
</j:jelly>
Very grateful for any help that can be provided!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 07:16 AM
You can try using the gs.getMessage functionality:
http://wiki.servicenow.com/index.php?title=GlideSystem#getMessage.28String.2C_Object.29&gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 07:16 AM
You can try using the gs.getMessage functionality:
http://wiki.servicenow.com/index.php?title=GlideSystem#getMessage.28String.2C_Object.29&gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 07:28 AM
Thank you for the quick response - much appreciated! I have changed my code to this:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_id" value="${jvar_cat_item.getID();}" />
<g:evaluate var="jvar_delivery_standard" jelly="true" expression="
var itemGr = new GlideRecord('sc_cat_item');
itemGr.get(jelly.jvar_id);
itemGr.u_delivery_standard;
" />
<j:if test="${jvar_delivery_standard > 0}">
<tr>
<td id="sc_delivery_time_label_cell"><strong>${gs.getMessage("Delivery Standard")}</strong></td>
<td id="sc_delivery_time_cell">${jvar_delivery_standard}</td>
</tr>
</j:if>
</j:jelly>
When I switch my language preference though, it still says Delivery Standard. If I go into my request item and right click on the field label and select "Configure label", I can see my translated value. Do I need to put this translated value somewhere else in order for it to get picked up?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 08:04 AM
It seems to be hidden in the messages table (sys_ui_message), see
http://wiki.servicenow.com/index.php?title=Language_Internationalization#Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 08:45 AM
Thank you, thank you, thank you!!!
This is exactly what I needed, much appreciated!