Need help in querying users in alphabetical order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2015 05:50 AM
Hi,
I am running a background script that queries all users & checks for duplicate notifications. I got the script all running, but when I run the script, I get an error as follows:
Large Table: Table handling an extremely large result set: 71441
Query that got us here is: TABLENAME = sys_user
Now, I need help in a script that I can use to query all the active users according to alphabetical order, so that I can run the script in batches.
Please respond ASAP.
Regards,
Shreyas Pattabhi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2015 05:52 AM
If you're using a gliderecord query you can use both gr.orderBy() and gr.setLimit().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2015 06:40 AM
Thanks Brad,
I tried for the same, but did not get much of a result. To be more precise, i'm looking at picking up users from a particular alphabet to another... for example say A-G. Can you please guide me in this regard?
var gnew = new GlideRecord('sys_user');
gnew.addActivequery();
gnew.orderBy('name');
gr.setLimit(1000);
gnew.query();
This is the code i"m using now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2015 08:10 AM
Hi Shreyas,
Just to add, you can use the combination of addQuery and setLimit to fetch few records as per the logic and update them in batch.