Count of how many times a particular email notification has been sent in defined time interval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 09:46 PM
We need to know the count of how many times a particular email notification has been sent in defined time interval. For example: We have 300 notification configured in sysevent_email_action table and the fact we want to know is which out of the 300 is mostly commonly and widely used. So we need the count of how many time each notification has been sent/triggered in past 6 months etc. It would be great if you can let us know on how to derive it. Is there any report or kind of background script which can fetch this details?
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 09:55 PM
Hi Kushan,
I think you can have report on email logs table.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 10:48 PM
We don't have notification name in the logs and subject cannot be used to represent a particular notification. Can you suggest how from the email logs we can link an email sent to particular notification.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 02:02 AM
Hi Kushan,
Please find the below code which will suffice your requirement:
This can be written wither in a background script/ Fix script-
var gr = new GlideRecord('sysevent_email_action');
gr.addEncodedQuery('active=true');
gr.query();
while(gr.next())
{
var count = 0;
// gs.print(gr.name);
var gr1 = new GlideRecord('sys_email_log');
gr1.addEncodedQuery('sys_created_onONLast 6 months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()');
gr1.query();
while(gr1.next())
{
//gs.print("gr: " +gr.sys_id);
//gs.print("gr1 :"+gr1.sys_id);
if(gr.sys_id == gr1.notification)
{
count++;
}
}
if(count!=0)
gs.print("Notification name: "+ gr.name + " Count: "+ count);
}
Please mark the answer as correct if it suffice your query.
Thanks.