Skip to content
Merged
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,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.
Original file line number Diff line number Diff line change
@@ -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));
Loading