Using GlideAggregate

aldo3
Kilo Explorer

Hi everyone.
I am new to service now and this is my 1st post so please don't be too harsh.

I started exploring UI pages and I want to start using GlideAggregate to make some custom reports.
I checked the service now wiki page and took the first example that is suppose to get a count of how many records in the incident table and I pasted that in a UI page I created and added an alert to show me the count.

I attached my full script (in a txt file) that I have put in the HTML section of my UI page.
I know it should be in the "Client Script" section but I know it should still work.

When I hit the "Try It" button, the page comes up with my "Custom report 1" header but I also get a Internet explorer warning icon saying that "GlideAggregate is undefined" and my alert does not come up.
I tried just leaving the "var count = new GlideAggregate('incident');" line and deleting the rest but same error comes up.

Could I be missing some type of plugin to make this work?
Any help in this matter would be greatly appreciated.
Thanks in advance.

4 REPLIES 4

Michael Kaufman
Giga Guru

Try this out:



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_incident_count">
var count = new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidentCount = 0;
if (count.next()) {
incidentCount = count.getAggregate('COUNT');
}
incidentCount;
</g2:evaluate>
<strong>Incident Count: </strong>$[SP]$[jvar_incident_count]
</j:jelly>


To add to Mike's comment. You'll want to check out http://wiki.servicenow.com/index.php?title=Content_Management_and_Jelly
This page will give you a basic understand of Jelly and some examples on how it interacts with Glide


aldo3
Kilo Explorer

Thanks Mike
I tried the script and it works great.
I really appreciate the time you spent helping me out.

I will start reading on how to use Jelly scripting and hopefully won't have to bother you guys anymore. 🙂

Thanks again.



No problem, glad it works for you!