Jelly script populating innerHTML

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 04:31 AM
I'm trying to get the following to work:
<?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 jelly="true">
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', '8a4cd5b36fd3d1000fd9122cbb3ee48f'); // "Service Desk" group sys_id.
gr.orderBy('user.name');
gr.query();
</g:evaluate>
<j:while test="${gr.next()}">
<div id="${gr.user.sys_id}"></div>
</j:while>
<g:evaluate jelly="true">
var gr2 = new GlideRecord('u_round_robin');
gr2.query();
while (gr2.next())
{
document.getElementById('gr2.u_user_sys_id').innerHTML = gr2.u_daily_tickets_assigned;
}
</g:evaluate>
</j:jelly>
This is the part that isn't working:
document.getElementById('gr2.u_user_sys_id').innerHTML = gr2.u_daily_tickets_assigned;
I'm sure that I'm not using jelly correctly. Can someone please advise?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 07:33 AM
Yeah, I didn't want to run a glideRecord query for every iteration of the first while() loop. Just seemed like bad code.
Anyway, the following code works. Thank you so much for your responses!
<?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 jelly="true">
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', '8a4cd5b36fd3d1000fd9122cbb3ee48f'); // "Service Desk" group sys_id.
gr.orderBy('user.name');
gr.query();
</g:evaluate>
<script>
var activeCount = 0;
var inactiveCount = 0;
function add(val)
{
if (val == "a")
activeCount++;
else if (val == "i")
inactiveCount++;
}
</script>
<style>
.trHover tr:hover td {background:#d7d7d7}
</style>
<table class="trHover">
<div id="stats">
</div>
<tr>
<td>
<span style="text-decoration: underline;">Technician</span>
</td>
<td>
<span style="text-decoration: underline;">#</span>
</td>
<td>
<span style="text-decoration: underline;">Last ticket assigned</span>
</td>
</tr>
<j:while test="${gr.next()}">
<tr>
<td>
<a target="_top" href="nav_to.do?uri=sys_user.do?sys_id=${gr.user.sys_id}">
<j:if test="${gr.user.u_round_robin_active}">
<span style="background-color: #5CE65C;font-weight: bold;">${gr.user.name}</span>
<script> add("a"); </script>
</j:if>
<j:if test="${!gr.user.u_round_robin_active}">
<i>${gr.user.name}</i>
<script> add("i"); </script>
</j:if>
</a>
</td>
<td width="10">
<span id="${gr.user.sys_id}">
<g:evaluate jelly="true">
var gdt = new GlideDateTime();
var month = gdt.getMonth();
var year = gdt.getYear();
var day = gdt.getDayOfMonth();
var gr2 = new GlideRecord('u_round_robin');
gr2.addQuery('u_year', year);
gr2.addQuery('u_month', month);
gr2.addQuery('u_day_of_month', day);
gr2.query();
</g:evaluate>
<j:while test="${gr2.next()}">
<j:if test="${gr.user.sys_id == gr2.u_user_sys_id}">
${gr2.u_daily_tickets_assigned}
</j:if>
</j:while>
</span>
</td>
<td>
<j:if test="${gr.user.u_round_robin_active}">
(${gr.user.u_last_ticket_assigned.getDisplayValue()})
</j:if>
<j:if test="${!gr.user.u_round_robin_active}">
 
</j:if>
</td>
</tr>
</j:while>
</table>
<script>
var tot = activeCount + inactiveCount;
document.getElementById("stats").innerHTML = "On: " + activeCount + "   Off: " + inactiveCount + "   Total: " + tot + "<br /><i>(color indicates Round Robin is activated)</i><br /><br />";
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2016 02:50 AM
hello,
I would like the code where you are inserting records in u_round_robin table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2016 05:21 AM
Sure. It's my Script Include, named: RoundRobin_Toggle
var RoundRobin_Toggle = Class.create();
RoundRobin_Toggle.prototype = Object.extendsObject(AbstractAjaxProcessor, {
RoundRobin_Toggle: function() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUser().getRecord().getValue('sys_id'));
gr.query();
if (gr.next())
{
var act = 99;
if (gr.u_round_robin_active == true)
{
gr.u_round_robin_active = false;
act = 0;
}
else if (gr.u_round_robin_active == false)
{
gr.u_round_robin_active = true;
act = 1;
}
gr.update();
var nowdt = gs.nowDateTime();
var gdt = new GlideDateTime();
var month = gdt.getMonth();
var year = gdt.getYear();
var day = gdt.getDayOfMonth();
var gr2 = new GlideRecord('u_round_robin');
gr2.initialize();
gr2.u_user_sys_id = gs.getUser().getRecord().getValue('sys_id');
gr2.u_user = gs.getUser().getRecord().getValue('name');
gr2.u_year = year;
gr2.u_month = month;
gr2.u_day_of_month = day;
gr2.u_timestamp = nowdt;
if (act == 0)
{
gr2.u_action = "Toggled INACTIVE";
}
else if (act == 1)
{
gr2.u_action = "Toggled ACTIVE";
}
else if (act == 99)
{
gr2.u_timestamp = '';
}
gr2.insert();
}
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2016 11:10 PM
Thankuu so much David. Is this being called in your Ui page