Email notification with incident numbers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
54m ago
Hi Community,
Here for the caller x , if created 25 incidents per day then we need those incident numbers in body of the email notification ? how it is possible?
Regards,
Tulasi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
27m ago
Hello @tulasi8 ,
Create an Email Notification, configure all the required details (table should be Incident obviously).
Put appropriate criteria like when to trigger , whom to send etc.
After that the most important part is to create Email Notification Script. Create the email notification script as shown below:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var incGr = new GlideRecord('incident');
incGr.addEncodeduery('priority=1^state=2');
incGr.query();
var incList = [];
while(incGr.next()){
var obj = {};
obj.number = incGr.getValue('number');
obj.person = incGr.caller_id.getDisplayValue();
obj.shortDesc = incGr.getValue('short_description');
obj.state = incGr.state.getDisplayValue();
incList.push(obj);
}
var htmlData = "<table><tr><th>NUMBER</th><th>CALLER PERSON</th><th>STATE</th><th>SHORT DESC</th></tr>";
template.print(htmlData);
incList.forEach(function(eachData){
var currentRow = "<tr><td>"+eachData.number+"</td><td>"+eachData.person+"</td><td>"+eachData.state+"</td><td>"+eachData.shortDesc+"</td></tr>";
template.print(currentRow);
});
template.print("</table>");
})(current, template, email, email_action, event);
After that call the email script in your email notification as shown below:
Now click on preview button to see the result:
As you can see the table list of all the incidents. You can do styling and filter condition to get those 25 incidents in your email script criteria.
All of this really takes time to put to help you understand kindly mark this solution as helpful.
Thank you,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
25m ago
Hi,
I would suggest you create a business rule upon submit of incident, that counts if the user has submitted 25 records within a day, and if so, fires an event that triggers the email notification.
In the email notification you can add all the relevant data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22m ago
-
Why does the recipient need all 25 numbers? What action are they expected to take?
-
What is the trigger for this email? Is it a daily summary, or the creation of the 25th incident?
Instead of creating a complex email script, the standard best practice is to set up a Scheduled Report or a Saved Filter that automatically gathers all 25 incidents and simply sends the recipient a link to that list in ServiceNow. This is scalable and directs the user to live, actionable data.
If my response has helped you, hit the helpful button, and if your concern is solved, do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
