How to go back to the first record for GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 10:39 PM
Hi all,
I am using GlideRecord like:
How to go back to the first record for GlideRecord:
var gr_incident = new GlideRecord("incident");
gr_incident.addQuery("xxx");
gr_incident.query();
while(gr_incident.next()) {
}
After the loop, I want to loop the gr_incident from the beginning again, but I don't want to query the db again, is it possible to do that?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 06:14 AM
Thanks @Gabriel Cabral for pointing this out. You are right. It doesn't work.
I tried running this script in my PDI and what you are pointing out is correct.
Is there a way we can achieve?
Thanks, and Regards,
Mahesh Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 07:47 AM
I think that most simple way is using GlideQuery:
var incidentArray = new GlideQuery('incident')
.where('active', true)
.select('number', 'short_description', 'state', 'state$DISPLAY')
.toArray(1000);