- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:02 PM
Hi everyone,
I have a while script that is working just fine in my background script, I just can't seem to fit it into my UI Page the right way. I think I am really close but something is just off...
This is the script working as a background script:
var count2 = new GlideAggregate('u_uwb');
count2.addQuery('u_state', 20);
count2.addAggregate('COUNT', 'u_your_name');
count2.query();
while (count2.next()) {
var person2 = count2.u_your_name.getDisplayValue();
var personCount2 = count2.getAggregate('COUNT', 'u_your_name');
}
I believe I am stuck on the 'while' loop part and assigning person2 and personCount2 their new values.
In my UI Page, I have this in the beginning:
<g:evaluate>
var count2 = new GlideAggregate('u_uwb');
count2.addQuery('u_state', 20);
count2.addAggregate('COUNT', 'u_your_name');
count2.query();
while (count2.next()) {
</g:evaluate>
and then later in the script when I try to fill out my table with the corresponding information I have the basic:
<table id="polines" width="90%" align="left" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td class="header center" colspan="1">Name</td>
</tr>
</thead>
<j:while test="${count2.next()}"
>
<tr>
<td width="10%" align="left">${person2}</td>
</tr>
</j:while>
Anywhere I put the while loop bit in, my ui page comes up with the header but no records? Any idea where I should be putting this piece or if it should be formatted differently? I tried putting it right under the query and then also within the <j:while> tags but it's just not quite right.
Any help would be greatly appreciated!
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 07:07 AM
Hi there ,
Try Below code
Crete New UI Page and paste code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var count2 = new GlideAggregate('incident');
count2.addQuery('state', 1);
count2.addAggregate('COUNT', 'caller_id');
count2.query();
</g:evaluate>
<br />
<table id="polines" width="90%" align="left" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td class="header center" colspan="1">Name</td>
<td class="header center" colspan="1">Count</td>
</tr>
</thead>
<j:while test="${count2.next()}">
<tr>
<td width="10%" align="left">${count2.caller_id.getDisplayValue(); }</td>
<td width="10%" align="left">${count2.getAggregate('COUNT', 'caller_id');}</td>
</tr>
</j:while>
</table>
<br />
<br />
</j:jelly>
If it work for you then replace your table and fields labels there
output on my side
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 06:40 AM
I don't want a count of the users. I want a count of how many records belong to that user. So if these are the records:
Bill Nighy
Emma Thompson
Hugh Grant
Hugh Grant
Bill Nighy
Hugh Grant
Colin Firth
I want the table to look like:
Bill Nighy 2
Emma Thompson 1
Hugh Grant 3
Colin Firth 1
Putting that bit of script in, looks like this is more of the chart I get...
Bill Nighy 4
Emma Thompson 4
Hugh Grant 4
Colin Firth 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 07:07 AM
Hi there ,
Try Below code
Crete New UI Page and paste code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var count2 = new GlideAggregate('incident');
count2.addQuery('state', 1);
count2.addAggregate('COUNT', 'caller_id');
count2.query();
</g:evaluate>
<br />
<table id="polines" width="90%" align="left" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td class="header center" colspan="1">Name</td>
<td class="header center" colspan="1">Count</td>
</tr>
</thead>
<j:while test="${count2.next()}">
<tr>
<td width="10%" align="left">${count2.caller_id.getDisplayValue(); }</td>
<td width="10%" align="left">${count2.getAggregate('COUNT', 'caller_id');}</td>
</tr>
</j:while>
</table>
<br />
<br />
</j:jelly>
If it work for you then replace your table and fields labels there
output on my side
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 07:36 AM
Aha yes!! Well done! That was it and definitely not one I had tried. Thanks for being awesome!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 10:16 PM
Thanks