Need to send an email with list of incidents which are not updated more than 2 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Need to send an email every day with list of incidents which are not updated more than 2 days. Here trigger condition is , if any incident is not updated more than 2 days
please guide me on how to achieve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You need to create a scheduled job for this and trigger the event from scheduled job to send the notification and in event parameter you need to pass a list of incidents in an array or in object so that you can use it in email body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
yes, exactly - a scheduled job or a flow.
Optimally use event and that would be a notification trigger, or you can send that notification from flow as well.
buuuuut be careful not to trigger each incident separately 😄 and also, these scheduled reports are usually executed early morning or late nights.
If you want to have in last 2 days, be careful not to send on Monday with no update during the weekend so exclude that...
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
email has to be sent to whom? Assigned to -> Manager with list of all INCs not updated by his/her Assignee in last 2 days?
what's your exact business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @VijayramY
You need create:
1 - Event (To triger the notification)
2 - Notification (Event is fired with your event)
3 - Mail scrip (with information that you need "list of incidents which are not updated more than 2 days"
4 - Schedule job (Run daily)
See some code exemples:
Schedule job:
(function() {
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@2'); // not updated in 2+ days
gr.addActiveQuery();
gr.query();
if (gr.hasNext()) {
gs.eventQueue("custom.incident.stale.report", null, "", "");
}
})();
Mail script:
// Mail Script: Incident not updated for 2+ days
(function() {
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@2'); // not updated in 2+ days
gr.addActiveQuery(); // only active incidents
gr.query();
var body = "";
body += "<p>Hello,</p>";
body += "<p>Here are incidents not updated for more than 2 days:</p>";
body += "<table border='1' cellpadding='5' cellspacing='0'>";
body += "<tr><th>Number</th><th>Short Description</th><th>Assigned To</th><th>Last Updated</th></tr>";
while (gr.next()) {
body += "<tr>";
body += "<td>" + gr.number + "</td>";
body += "<td>" + gr.short_description + "</td>";
body += "<td>" + gr.assigned_to.getDisplayValue() + "</td>";
body += "<td>" + gr.sys_updated_on.getDisplayValue() + "</td>";
body += "</tr>";
}
body += "</table>";
body += "<br/><p>Regards,<br/>ServiceNow</p>";
template.print(body);
})();
Step 3: Create a Notification
- Go to System Notification → Email → Notifications.
- Create a new notification:
- When to send: Event is fired.
- Event name: custom.incident.stale.report.
- Who will receive: desired group, distribution list, or email addresses.
- What it will contain: add a Mail Script.