- 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-10-2023 07:52 AM
Not a good practice and not at all recommended.
if they are already receiving the file why to send the same data in email body.
Consider the excel contains 100-400 records satisfying the report condition how the email will look with data for those 100-400 records
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
08-10-2023 07:55 AM
Hi Vaishali,
Did you try to check the reason for it? What if scheduled reports has hundered or thousands of records? The body of the notification will explode.
If you still want, you can write a mail script & call the mail script in the scheduled report to get it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:10 AM - edited 08-11-2023 05:10 AM
There is a slight change in the requirement. The user now wants only the count of the records(that are sent through the excel) in the email body.
How this can be done?
Thanks in advance!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:11 AM
You still need mail script to be in place & you can return the count using GlideRecord in the mail script.