Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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,15 @@
(function() {
var priorities = {};
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT');
agg.groupBy('priority');
agg.query();
while (agg.next()) {
var priority = agg.getDisplayValue('priority') || 'No Priority Set';
var count = agg.getAggregate('COUNT');
priorities[priority] = parseInt(count, 10);
}
for (var priority in priorities) {
gs.info('Priority: ' + priority + ' | Count: ' + priorities[priority]);
}
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//To get the incident count based on priority.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Auto Close Incidents after 7 days in Resolved state
(function() {
var grInc = new GlideRecord('incident');
grInc.addQuery('state', '6'); // 6 = Resolved
grInc.addQuery('resolved_at', '<=', gs.daysAgoStart(7));
grInc.query();

while (grInc.next()) {
grInc.state = 7; // 7 = Closed
grInc.close_notes = 'Automatically closed after 7 days of resolution.';
grInc.update();
// gs.info('Closed Incident: ' + gr.number);
}
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Auto-Close Resolved Incidents After 7 Days

Table: Incident
When: Before
Condition: State is Resolved and resolved_at older than 7 days.
This script automatically closes any Incident that has been in a "Resolved" state for 7 days.

// Use Case :
Keeps your Incident queue clean and ensures SLA metrics stay accurate.

// How :
Queries incident table.
Finds records with state = Resolved and resolved_at older than 7 days.
Changes state to Closed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//Restrict System Generated Comments from Updating ITIL Metrics on the task metric reporting table.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//Table: Task Metric Reporting Table.
//When to run:Before update
//Conditions: Updated by is system

//Script
(function executeRule(current, previous /null when async/ ) {

var caseSysid = current.u_task_number.sys_id;
var grCase = new GlideRecord('sn_customerservice_case');
if (grCase.get(caseSysid)) {
var latestEntry = grCase.comments.getJournalEntry(1).toString();
var latestWorknote = grCase.work_notes.getJournalEntry(1).toString();
if (latestEntry.includes('System') || latestWorknote.includes('System')) {
current.setAbortAction(true);
}
}
Loading