Except when using get(), or in a situation such as a business rule where a GlideRecord is already defined for you, calling the query() method is a necessary step before you can do anything to any records in the database:
var gr = new GlideRecord('incident');
gr.addQuery('active', 'true');
gr.orderBy('priority');
gr.query();
while (gr.next()) {
//do something
}