How to get the display values of a choice list field in Jelly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2014 01:40 AM
So I am rendering a choice list field in a UI macro. I am able to get the element and O can call .getChoices() which returns the internal values of the choices. But what about the display values for the choices? Any ideas?
<g:evaluate jelly="true">
var element = gr.getElement(jelly.jvar_field);
var elemDesc = element.getED();
</g:evaluate>
<j:if test="${elemDesc.isChoiceTable()}">
<select>
<j:forEach items="${j2js(element.getChoices())}" var="jvar_choice">
<option value="${jvar_choice}">${jvar_choice}</option>
</j:forEach>
</select>
</j:if>
I've tried using getChoiceValue() and getDisplayValue but both return null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2014 02:46 AM
Hi Nathan,
Did you ever solve this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2014 03:13 PM
Warren,
I did. I dont think it's documented anywhere and I forget how I found it, but I believe you have to ditch the "getChoices()" method and use the following instead:
<select name="" class="form_field">
<j:forEach items="${GlideScriptChoiceList.getChoiceList(gr.getTableName(), element.getName())}" var="jvar_choice">
<option value="${jvar_choice.value}">
${jvar_choice.label}
</option>
</j:forEach>
</select>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015 09:33 AM
WOW, this is a lifesaver. I saved 20+ hours of my life.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2018 01:26 AM
Requesting your attention to this post Nathan. Kindly take a look:
https://community.servicenow.com/community?id=community_question&sys_id=486d5571db246f802be0a851ca961952