From d56aa073b6163116c8440c9a8eb49677b10e9a25 Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Thu, 9 Oct 2025 00:07:49 +0800 Subject: [PATCH 1/2] Create get-outstanding-incidents.js --- .../get-outstanding-incidents.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Get Outstanding Incidents/get-outstanding-incidents.js diff --git a/Server-Side Components/Background Scripts/Get Outstanding Incidents/get-outstanding-incidents.js b/Server-Side Components/Background Scripts/Get Outstanding Incidents/get-outstanding-incidents.js new file mode 100644 index 0000000000..43eb3584db --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Outstanding Incidents/get-outstanding-incidents.js @@ -0,0 +1,26 @@ +var result = []; + var gr = new GlideRecord('incident'); + gr.addQuery('active', true); + var startOfMonth = new GlideDateTime(); + startOfMonth.setDisplayValue(gs.beginningOfThisMonth()); + gr.addQuery('sys_created_on', '<', startOfMonth); + + gr.query(); + + while (gr.next()) { + result.push({ + number: gr.getValue('number'), + short_description: gr.getValue('short_description'), + assigned_to: gr.getDisplayValue('assigned_to'), + sys_created_on: gr.getDisplayValue('sys_created_on'), + state: gr.getDisplayValue('state') + }); + } + + var output = { + total_count: result.length, + generated_on: gs.nowDateTime(), + outstanding_incidents: result + }; + + gs.print(JSON.stringify(output,null,2)); From c2f6db7b7447d3a5a80341e3111d15a1d124276e Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Thu, 9 Oct 2025 00:10:41 +0800 Subject: [PATCH 2/2] Create README.md --- .../Background Scripts/Get Outstanding Incidents/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Get Outstanding Incidents/README.md diff --git a/Server-Side Components/Background Scripts/Get Outstanding Incidents/README.md b/Server-Side Components/Background Scripts/Get Outstanding Incidents/README.md new file mode 100644 index 0000000000..9e71d20f00 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Outstanding Incidents/README.md @@ -0,0 +1,5 @@ +# ServiceNow Background Script — Outstanding Incidents Before Current Month (JSON Output) + +This background script retrieves all "active" incidents created before the start of the current month, and outputs the results in JSON format. + +It is useful for reporting involving aging incident records.