- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 07:41 AM
I have 2 scheduled reports on incident & ritm table respectively and the data is sent through excel format. The user wants that the records which are there in the excel can also be seen in the email body.
Is that feasible to do? If yes, how can it be done?
Thanks in advance!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:18 AM
System Notificaiton >> Email >> Mail script
(function runMailScript(current, template, email, email_action, event) {
var inci=new GlideRecord('incident');
//inci.addQuery('')//pass relevant query here as per report
inci.query();
template.print('Inci count is '+inci.getRowCount());
}
})(current, template, email, email_action, event);
Call mail script in format
${mail_script:getcountofrecords}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 06:07 AM
Hello @Vaishali 11 ,
You can actually write an email script for this to fetch the count of the records .
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('active',true);
gr.query();
template.print ("RITM Count "+ gr.getRowCount());
var inc = new GlideRecord('incident');
inc.addQuery('active',true);
inc.query();
template.print ("Incident Count "+ inc.getRowCount());
})(current, template, email, email_action, event);
Also call the email script in the notification
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:13 AM
Could you please provide me an overview of that how that can be done
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:18 AM
System Notificaiton >> Email >> Mail script
(function runMailScript(current, template, email, email_action, event) {
var inci=new GlideRecord('incident');
//inci.addQuery('')//pass relevant query here as per report
inci.query();
template.print('Inci count is '+inci.getRowCount());
}
})(current, template, email, email_action, event);
Call mail script in format
${mail_script:getcountofrecords}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:24 AM
Hi Jaspal,
In the report the condition is being written on assignment group, state and opened.
Are you referring to that for the query?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:25 AM
Yes, that is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 06:07 AM
Hello @Vaishali 11 ,
You can actually write an email script for this to fetch the count of the records .
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('active',true);
gr.query();
template.print ("RITM Count "+ gr.getRowCount());
var inc = new GlideRecord('incident');
inc.addQuery('active',true);
inc.query();
template.print ("Incident Count "+ inc.getRowCount());
})(current, template, email, email_action, event);
Also call the email script in the notification
Hope this helps
Mark my answer correct if this helps you
Thanks