- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2018 07:59 AM
HI All,
I have written below given script:
var grTemplate=new GlideRecord('sys_template');
grTemplate.query();
gs.print(grTemplate.getRowCount());
while(grTemplate.next()){
gs.print(grTemplate.sys_id);
}
I want to print the sys_id of each record but its not getting printed...Can anyone tell me what can be the issue here?
Thanks,
Faruk
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2018 08:15 AM
@t_anurag is correct that with the sys_template table you have to use "_next()" and that is because there is a field named "next" on the sys_template table. With your original script it is looking at that attribute and not going to the next record, thus _next() makes it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2018 08:05 AM
Hi Faruk,
This will work
var grTemplate=new GlideRecord('sys_template');
grTemplate.query();
gs.print(grTemplate.getRowCount());
while(grTemplate._next()){ //changed this to _next()
gs.print(grTemplate.sys_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2018 08:15 AM
@t_anurag is correct that with the sys_template table you have to use "_next()" and that is because there is a field named "next" on the sys_template table. With your original script it is looking at that attribute and not going to the next record, thus _next() makes it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2019 09:52 AM
Thank you! That was about 30 minutes of my life that I can never get back trying to figure this out! 🙂 Thanks so much for posting this and answering it!