logo

NJP

Learn MORE JavaScript on the ServiceNow Platform: Lesson 9 Exercise - GlideAggregate

Import · Dec 12, 2023 · video

Hi, everyone. Exercise time. So in this one, it's
pretty straightforward, especially if you followed
along the lesson in the last video. But go ahead and use GlideAggregate
to calculate the average priority of incidents
for every assignment group. I have a few hints
if you've never done an average before. It's just like the other one though,
so it should be pretty straightforward. Go ahead and pause the video now
so that you can try the exercise and then we'll compare answers
right after that. bye. And we're back. Okay. Let's see if we got the same thing. First, I created a new GlideAggregate
on the incident table, and then I group to buy
a assignment_group. And then I added aggregate of average. But I made sure to say
for the priority field. And then I queried it. And then I looped through
all of those records using .next(). And then I logged the statement. And you'll see here that I did .getDisplayValue() of the assignment_group
so that we could return the pretty version of the name instead of the sys_id and then getAggregate() of the average
and set priority. Let's go ahead and take that code
and then throw it into ServiceNow and run it. And there you go. That's the average priority
for all of my incidents by the assignment group. This is fun data. I can see that the Openspace assignment
group has very high priority incidents. I could see that database has very low priority incidents
and just fun numbers to crunch. Cool. How did you do?

View original source

https://www.youtube.com/watch?v=FKM_vRwH65A