1. Query active P1 incidents
“Write a script to log the number of active P1 incidents.”
Script
var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.addQuery('priority', 1);
gr.query();
gs.info('Active P1: ' + gr.getRowCount());Why it works
addActiveQuery() is shorthand for active=true. getRowCount() returns the matched count without iterating.
Alternate approach
Use GlideAggregate('incident') with addAggregate('COUNT') for a single DB call instead of loading rows.