Step 4: Process Returned Records With Script Logic

  • next() moves to the next record in the GlideRecord object

    • while() iterates through all returned records
    while(myObj.next()) {
    //script logic
    // Reference current record as <object name>.<property> (e.g. myObj.state)
    }
    

    -if() process onle the first record returned

    if(myObj.next()) {
    //script logic
    }
    
  • hasNext() steps through returned records and determines if there are any more records

    if(myObj.hasNext()) {
    //script logic
    }
    

.hasNext returns true when there is a next record, but does not load that record into the object for processing. Select this method to execute script logic when a next record simply exists, but access to the record's data is not needed.

By default queries with invalid field names run but ignore the invalid condition. A true/false glide.invalid_query.returns_no_rows System Property can be added to the System Property table with its value set to true to instead have invalid queries return no rows in the GlideRecord object.

The method _next() has the same functionality as next(). It is intended to be used on tables where there is a column named 'next', which would interfere with using the next() method.

results matching ""

    No results matching ""