- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:20 AM
need to iterate records, so insted of while i used for loop .
I tried like this but it's not working any idea provide me.
Out put returning undefined
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:36 AM
By the way, don't use GlideRecord to get the count.
Quite a few issues in the code. Even addQuery isn't correct
try this instead
var ga = new GlideAggregate('incident');
ga.addQuery('priority', '=', '4');
ga.addAggregate('COUNT');
ga.query();
var count = 0;
if (ga.next()) {
count = ga.getAggregate('COUNT');
}
// Log or use the count
gs.info('Count of incidents with priority 4: ' + count);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:24 AM
Try arr[i].number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:27 AM
Not working
I think in 5th line iam assigned correct or not I don't know,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:34 AM
Hi there,
What's the reason for not using normal construction of while, performing .next() etc.? Or can you explain what you functionally are after? This just looks really odd.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:36 AM
By the way, don't use GlideRecord to get the count.
Quite a few issues in the code. Even addQuery isn't correct
try this instead
var ga = new GlideAggregate('incident');
ga.addQuery('priority', '=', '4');
ga.addAggregate('COUNT');
ga.query();
var count = 0;
if (ga.next()) {
count = ga.getAggregate('COUNT');
}
// Log or use the count
gs.info('Count of incidents with priority 4: ' + count);