- 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:49 AM - edited 02-11-2024 03:50 AM
Hi @Sonam_Tiwari @Mark Roethof
I am trying with for loop, insted of while(gr.next())
In interview they asked me this question with out while how iterate elements and print the numbers so I said with for loop keep elements in array and loop with for. So now I am trying with this how can achive.