- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2015 05:18 AM
Hi,
I have a list, by default it will fetch comma separated values, but I want values of list to be line separated not comma separated.
Example,
list is: abc,xyz,mno
result= abc,xyz,mno
expected result= abc
xyz
mno
In my table I have a field of type 'list' which takes multiple values. I am fetching the records and displaying it in my UI page.
The field name is u_team. When I print it using $[u_team], the result is displayed with comma separated, e.g. abc,xyz,mno
I tried using forEach but I didn't get the expected result.
I tried with for loop in client script of my Ui page, it worked fine but am not able to do that in HTML using forEach.
Client Script Code: (works fine)
function userList(names){
alert(names);
var array=names.split(",");
for (var i=0; i < array.length; i++) {
alert(array[i]);
}
}
How can I achieve this?
Thanks,
Sowmya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2015 10:12 AM
HI Sowmya,
see below code. it is in phase1 but you can replace g to g2, j to j2 and {} to [] for phase2.
<g:evaluate>
var gr = new GlideRecord('incident');
gr.get('e8caedcbc0a80164017df472f39eaed1');
var list = gr.u_todo.getDisplayValue(); <!-- todo is a list field -->
var one = list.split(',');
</g:evaluate>
<j:forEach var='jvar_item' items='${one}'>
<h3>
${jvar_item}
</h3>
</j:forEach>
let me know if this works.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2015 07:10 AM
Hi Sowmya,
Could you post the code you used for your ui page? If you have your value as a comma separated list in the jelly, you could just run a javascript replace() to replace the commas with html line breaks (<br/>).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2015 10:12 AM
HI Sowmya,
see below code. it is in phase1 but you can replace g to g2, j to j2 and {} to [] for phase2.
<g:evaluate>
var gr = new GlideRecord('incident');
gr.get('e8caedcbc0a80164017df472f39eaed1');
var list = gr.u_todo.getDisplayValue(); <!-- todo is a list field -->
var one = list.split(',');
</g:evaluate>
<j:forEach var='jvar_item' items='${one}'>
<h3>
${jvar_item}
</h3>
</j:forEach>
let me know if this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2015 11:57 PM
Hi Rushit,
Thanks a lot. It's Working
Thanks,
Sowmya