How to Automate Daily Notifications for Open Incidents Till the Previous Day in ServiceNow?

kusumgautam
Tera Contributor

On daily bases I want to send an notification to the manager of like what all incident open till the previous date.

 

Should I use a Scheduled Job, Workflow, or Notification to achieve this, and what would the best approach be for such a use case?

 

Thank you

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hi @kusumgautam 

There are multiple ways like :-
1. use flow designer --> choose trigger as scheduled job(run daily) --> add action send notification --> choose your notification with appropriate filter.
2. Use Schedule job script to trigger the Notification by Gliding to the table(incident) and Achieve it .
3. In workflow also you can use run script to glide to the table and fetch data and triiger notificvation using gs.eventQueue()

sample Script :-

(function executeScheduledJob() {
var x= new GlideRecord('incident');
x.addQuery('state', '!=', '7'); // Exclude closed incidents
x.addQuery('opened_at', '<', gs.daysAgoStart(1)); // Opened before yesterday
x.query();

var incidentList = [];
while (x.next()) {
incidentList.push(x.number + " - " + x.short_description);
}

if (incidentList.length > 0) {
gs.eventQueue("custom.incident.notification", null, "manager@example.com", incidentList.join("\n"));
}
})();


View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage

Hi @kusumgautam 

There are multiple ways like :-
1. use flow designer --> choose trigger as scheduled job(run daily) --> add action send notification --> choose your notification with appropriate filter.
2. Use Schedule job script to trigger the Notification by Gliding to the table(incident) and Achieve it .
3. In workflow also you can use run script to glide to the table and fetch data and triiger notificvation using gs.eventQueue()

sample Script :-

(function executeScheduledJob() {
var x= new GlideRecord('incident');
x.addQuery('state', '!=', '7'); // Exclude closed incidents
x.addQuery('opened_at', '<', gs.daysAgoStart(1)); // Opened before yesterday
x.query();

var incidentList = [];
while (x.next()) {
incidentList.push(x.number + " - " + x.short_description);
}

if (incidentList.length > 0) {
gs.eventQueue("custom.incident.notification", null, "manager@example.com", incidentList.join("\n"));
}
})();