- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-21-2019 06:01 PM
Hi,
I am doing like this
var ga = new GlideAggregate(theTable); ga.addAggregate('COUNT', dpField); ga.addHaving('COUNT', dpField, '>', '1'); ga.query(); var arDupes = new Array(); while (ga.next()) { arDupes.push(ga.getValue(dpField)); } Unfortunately I am getting all array elements are same and last value.
But if I put his.info then it is logging different values.
Please help me why is this behaviour ?
Thanks
JG
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-21-2019 06:08 PM
I believe you meant when you do gs.addInfoMessage(ga.getValue(dpField)) you are getting different values ?
In such case just modify your line of code from
var arDupes = new Array();
to
var arDupes = [];
Try this and let me know what you get after iterating through the array ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-21-2019 06:08 PM
I believe you meant when you do gs.addInfoMessage(ga.getValue(dpField)) you are getting different values ?
In such case just modify your line of code from
var arDupes = new Array();
to
var arDupes = [];
Try this and let me know what you get after iterating through the array ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-21-2019 07:50 PM
Hello JG,
GlideAggregate
GlideAggregate examples
-----------Executed in BackGround Script-------------------------
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT','category');
ga.addHaving('COUNT', 'category', '>', '1');
ga.query();
var arDupes = [];
while (ga.next()) {
arDupes.push(ga.getValue('category'));
}
gs.print(arDupes);
-------output---------------------
*** Script: database,hardware,inquiry,network,software
--------------------------------
Mark answer as correct and helpful if it helped you..!!
Regards,
Chalan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-21-2019 09:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-22-2019 09:23 AM
Hey JG,
What exactly are you trying to do and how are you doing it ? Can you help us with an example ?
Unfortunately I am getting all array elements are same and last value.
But if I put his.info then it is logging different values.
How are you printing the array elements ? Can you walk us through the exact code ?