- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:18 AM
Hi,
I was running a simple background script to get the sys_id of each record in the table. But I am able to get only 50000 sys_id only even though the table has the more than 1 lac records.
Can any one tell me is there any limitation that how many records can be fetched in background script at a time?
Below is the script I am using for reference:
var gr = new GlideRecord("sys_user_grmember");
gr.query();
while(gr.next()){
gs.print(gr.sys_id);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:30 AM
Hello @Ajay95
It may happens due to linear search of records, as it is quite time consuming. so it is showing only 50K records,
You need to Apply the bg script 2 times :-
gr.setLimit(50000); // First 50K records.
gr.chooseWindow(50000, 100000); // For next 50K Records.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:27 AM
Hello @Ajay95 ,
Try creating a scheduled job and return the same output in a log.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:31 AM
Hi Nayan
Thanks for the reply.
But is it the limitation of background script to return 50k records only at a time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:34 AM
Hello @Ajay95 ,
Yes as background scripts run on the server it takes time to load and query all the records. Hence the action might be aborted based on it.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:30 AM
Hello @Ajay95
It may happens due to linear search of records, as it is quite time consuming. so it is showing only 50K records,
You need to Apply the bg script 2 times :-
gr.setLimit(50000); // First 50K records.
gr.chooseWindow(50000, 100000); // For next 50K Records.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh