Iterating over query records

Once we fire a query, the next important thing we need to be able to perform is iterating over the record set or query set retrieved from the database. Iterating over a query set can be done using the next() method, which acts as an iterator and returns true till there exists the next record; otherwise, returns false when there are no more records in the query set:

var gr = new GlideRecord('incident');   
gr.addQuery('priority', '1'); 
gr.query(); 
while ( gr.next() ) { 
gs.print( gr.getValue('number')+ " exists");  //number is a field in incident table // the getValue method returns string  
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.152.173