From bdcc4599060c24d31688f0b36bf2f5630bffdd4d Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:06:31 +0530 Subject: [PATCH 1/2] script.js --- .../Generate Report in Logs/script.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Generate Report in Logs/script.js diff --git a/Server-Side Components/Background Scripts/Generate Report in Logs/script.js b/Server-Side Components/Background Scripts/Generate Report in Logs/script.js new file mode 100644 index 0000000000..cad77d65c7 --- /dev/null +++ b/Server-Side Components/Background Scripts/Generate Report in Logs/script.js @@ -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 ==="); +})(); From 5e3ec16b4e13804392041cb69b62b1c2e37676c9 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:07:29 +0530 Subject: [PATCH 2/2] readme.md --- .../Background Scripts/Generate Report in Logs/readme.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Generate Report in Logs/readme.md diff --git a/Server-Side Components/Background Scripts/Generate Report in Logs/readme.md b/Server-Side Components/Background Scripts/Generate Report in Logs/readme.md new file mode 100644 index 0000000000..10921555be --- /dev/null +++ b/Server-Side Components/Background Scripts/Generate Report in Logs/readme.md @@ -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.)