- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 09:59 AM
Hello,
When I run this script below as a background script, I get back a list of incident sys_ids, as expected:
var rec = new GlideRecord('incident');
rec.query();
while(rec.next()){
gs.print('The record sys_id is: ' + rec.sys_id);
}
But when I run this one below, hoping to get back a list of template sys_ids:
var rec = new GlideRecord('sys_template');
rec.query();
while(rec.next()){
gs.print('The record sys_id is: ' + rec.sys_id);
}
I instead get this:
Evaluator: org.mozilla.javascript.EcmaError: is not a function.
Caused by error in script at line 4
1: var rec = new GlideRecord('sys_template');
2: rec.query();
3: while(rec.next()){
==> 4: gs.print('The record sys_id is: ' + rec.sys_id);
5: }
Evaluator: org.mozilla.javascript.EcmaError: is not a function.
Caused by error in script at line -1
Can anyone explain what's going on here?
Thanks
Jamie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 10:06 AM
on sys_template, there is already a column called "next", hence the error.
you should be using _next()
- var rec = new GlideRecord('sys_template');
- rec.query();
- while(rec._next()){
- gs.print('The record sys_id is: ' + rec.sys_id);
- }
http://wiki.servicenow.com/index.php?title=GlideRecord#_next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 10:06 AM
on sys_template, there is already a column called "next", hence the error.
you should be using _next()
- var rec = new GlideRecord('sys_template');
- rec.query();
- while(rec._next()){
- gs.print('The record sys_id is: ' + rec.sys_id);
- }
http://wiki.servicenow.com/index.php?title=GlideRecord#_next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 01:31 PM
A-ha... yes, I'm sure I've come across this before!
Thank you Abhi - speedy response