- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 02:48 AM
Hello, all. This script is meant to produce a list of active users but skipped ~1,500. What am I doing wrong?
Thank you in advance!
-Tim
var users = new GlideRecord('sys_user');
users.addQuery('active', true); //Active users only
users.query();
while (users.next()) {
users.next();
gs.info(users.user_name);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 03:02 AM
Hello @timnardoni ,
You're using the "next()" method twice per loop. That's why every second user is skipped.
Please remove the second one, so that it looks like this:
var users = new GlideRecord('sys_user');
users.addQuery('active', true); //Active users only
users.query();
while (users.next()) {
gs.info(users.user_name);
}
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 06:39 AM
Hello @timnardoni ,
Thanks for the feedback.
One quick note: please do not use getRowCount in production code, as it can cause performance issues. See here for a discussion and a better alternative.
Regards,
Robert