GlideRecord - query(Object field, Object value)

Runs the query against the table based on the filters specified by addQuery() and addEncodedQuery().

This method queries the GlideRecord table as well as any references of the table. Usually this method is called without arguments, but a name/value pair can be specified.

Table 1. Parameters
Name Type Description
name Object Field name
value Object Value
Table 2. Returns
Type Description
void

Scoped equivalent

To use the query() method in a scoped application, use the corresponding scoped method: Scoped GlideRecord - query(Object field, Object value).

var rec = new GlideRecord('incident');
rec.query();
while (rec.next()) { 
 gs.print(rec.number + ' exists');
}