March 2017
Beginner
358 pages
9h 51m
English
Here, we use hasNext() as the loop condition, and call next() inside the loop:
var query = 'active=false^closed_atRELATIVELT@year@ago@2'; var gr = new GlideRecord('incident'); gr.addQuery(query); gr.query(); while (gr.hasNext()) { gr.next(); //do something }
We can simplify this loop by using .next() in the loop condition, since it returns true (when called) if it was successful in pulling a new record, and false if it wasn't. next() is documented later in this chapter.
Read now
Unlock full access