Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This script is used to generate quick, data-driven summaries directly in the system logs, without the need to create or view a ServiceNow report.
It’s helpful for Getting quick record counts (by state, priority, assignment group, etc.)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Script: Generate Report in Logs
// Author: Bhavya
// Purpose: Print summary counts for incidents in the system logs

(function() {
gs.print("=== Incident Summary Report ===");

// Total number of incidents
var total = new GlideAggregate('incident');
total.addAggregate('COUNT');
total.query();
total.next();
gs.print("Total Incidents: " + total.getAggregate('COUNT'));

// High Priority incidents
var high = new GlideAggregate('incident');
high.addQuery('priority', 1);
high.addAggregate('COUNT');
high.query();
high.next();
gs.print("High Priority Incidents: " + high.getAggregate('COUNT'));

// Active incidents
var active = new GlideAggregate('incident');
active.addQuery('active', true);
active.addAggregate('COUNT');
active.query();
active.next();
gs.print("Active Incidents: " + active.getAggregate('COUNT'));

// Resolved incidents
var resolved = new GlideAggregate('incident');
resolved.addQuery('state', 6); // Resolved
resolved.addAggregate('COUNT');
resolved.query();
resolved.next();
gs.print("Resolved Incidents: " + resolved.getAggregate('COUNT'));

gs.print("=== End of Report ===");
})();
Loading