- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2025 09:27 AM
Hello Team,
I have created and scheduled a report. I would like to include the number of records in the email body. Could you please advise on how to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2025 09:38 AM
ServiceNow’s Scheduled Reports do not natively provide a way to include a record count in the email body, you can achieve this using the below code in the mail script change table name and filters:
Mail script :
var gr = new GlideAggregate('incident'); // Change table name as needed
gr.addQuery('active', true); // Apply your conditions
gr.addAggregate('COUNT');
gr.query();
var recordCount = 0;
if (gr.next()) {
recordCount = gr.getAggregate('COUNT');
}
Please Mark this helpful
Regards
Priyatam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2025 09:36 AM
Hi @BibekP
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2025 09:38 AM
ServiceNow’s Scheduled Reports do not natively provide a way to include a record count in the email body, you can achieve this using the below code in the mail script change table name and filters:
Mail script :
var gr = new GlideAggregate('incident'); // Change table name as needed
gr.addQuery('active', true); // Apply your conditions
gr.addAggregate('COUNT');
gr.query();
var recordCount = 0;
if (gr.next()) {
recordCount = gr.getAggregate('COUNT');
}
Please Mark this helpful
Regards
Priyatam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2025 09:51 AM
you can use email script in scheduled email body and print the record count based on your report filter conditions
Scheduling a report with an inline table in mail body with the attachments
Embed List Reports in a Scheduled Report Email
Scheduling a report for dynamic Recipients based on the table column of the report
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
‎03-18-2025 11:44 AM
Hello @BibekP
Last I tried, score based report was not generating any attachment in the email that was scheduled.
So it's better to go via script and show the count in the email body. Mail script would work in this scenario definitely.
Kindly mark my answer as helpful and accept solution if it helped you in anyway,
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY