ServiceNow
JavaScript
GlideRecord
Just testing out GitHub pages for blogging, with a basic GlideRecord query for getting a list of all Priority 1 incidents:
1
2
3
4
5
6
7
8
9
10
| // Get all priority 1 incidents
var incGR = new GlideRecord('incident');
incGR.addQuery("priority", 1);
incGR.addActiveQuery();
incGR.query();
if ( incGR.hasNext() ) {
while ( incGR._next() ) {
gs.info(incGR.number);
}
}
|
GlideAggregate example for counting the number of computers by location:
1
2
3
4
5
6
7
8
9
10
| var ga = new GlideAggregate('cmdb_ci_computer');
ga.addAggregate('COUNT');
ga.groupBy('location');
ga.query();
while (ga.next()) {
var location = ga.getValue('location');
var count = ga.getAggregate('COUNT');
gs.info('Location: ' + location + ' - Count: ' + count);
}
|