How to display values using of an array using for loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 02:45 AM
Hi All,
In my table there is a field "Team" of type "List". I'm selecting more than one member in that field. Now I want to display the values of that filed one after another.
code:
<td>$[escalation.u_team.getDisplayValue()]</td>
When I try to display the values using the above code, I got the result as "Quintin Isacson, Waldo Edberg".
I need the values to be displayed in the below format:
Quintin Isacson
Waldo Edberg
I used foreach tag but it is not working.
Here is the code using "foreach"
<tr>
<td class="a2_td">
<g:evaluate>
var list = escalation.u_team.getDisplayValue();
<!--var array = list.split(","); -->
</g:evaluate>
<j:forEach items="${list}" var="jvar_array">
<g:evaluate jelly="true">
var name = jelly.jvar_array;
</g:evaluate>
<p>
User: $[SP] <span>${name}</span>
</p>
</j:forEach>
</td></tr>
Any clue on how to make this code work?
Thanks,
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 02:59 AM
Hi Jennifer,
You might find this answer helpful:
Of course, you will need to adapt the script to jelly.
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 05:13 AM
u_team.getDisplayValue() will give a comma separated list of display values.. Split using ',' and loop through the resulting array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 10:42 PM
Hi Kalai,
I did the same way but it is not working. When I try to display the values of array using ForEach I'm getting blank column and values are not displayed.
Here is the part of code where I use ForEach in HTML part of my UI page:
<j:jelly>
<g2:evaluate>
var escalation=new GlideRecord('u_escalation_level');
escalation.orderByDesc('u_level');
escalation.query();
</g2:evaluate>
<g2 height="200px">
<table class="a2_table">
<tr>
<th class="a2_th" width="100%"><h4><b>Escalation Level</b></h4></th>
</tr>
</table>
<table class="a2_table">
<tr>
<th class="a2_th"><h4><b>Team</b></h4></th>
</tr>
<j2:while test="$[escalation.next()]">
<tr>
<td class="a2_td">
<g:evaluate>
var list=escalation.u_team.getDisplayValue();
var array=[];
array = list.split(",");
</g:evaluate>
<j:forEach items="${array}" var="jvar_users">
<g:evaluate jelly="true">
var name = jelly.jvar_users;
</g:evaluate>
<p>
User: $[SP} <span>${name}</span>
</p>
</j:forEach>
</td>
</tr>
</j2:while>
</table>
</g2>
</j:jelly>
Thanks,
Jenny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 11:13 PM
Hi Jennifer,
Have you tried alerting the array[0] after you split to check if there is a value in it?