GlideAggregate Count

kuttti
Kilo Guru

 

 

var agg = new GlideAggregate('sp_log');

agg.addQuery('page=5c639f611be0591028a38625624bcbf5^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg.groupBy('user');
agg.addAggregate("COUNT");
agg.query();
while (agg.next()) {
gs.print("Count is "+agg.getAggregate("COUNT"));
}

 

 

Hello Community,

 

I am trying to pull unique number of users accessed some page through script using GlideAggregate but ideally I should get count 1 but here I am getting 2 it is just single user . Help needed in fixing the code

 

2 REPLIES 2

Community Alums
Not applicable

You're filtering just the dates on sp_log page. Do you consider yourself a user that also visited that page? You need to do more specific query or GlideRecord query for necessary user. Depends on your business case.

 

@Community Alums yes I visited page today 2 times but the number of users visited page should be just 1 because I am the same user who visited it two times.