How to get Report Data in the Subject of the Scheduled Reports ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 08:08 PM
We have a client requirement that they want to see the Reports final ticket count in the subject line of the scheduled report. Eg - The scheduled report is for open incident within 24 hrs and that report has 10 incidents data , so they want that count to be displayed in the Subject line.
I tried calling the script include using javascript: but it didn't work.
Please help me with this requirement, Thanks in Advance
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 08:20 PM
Hi Ayushi,
Are you sending an excel file or csv file in the scheduled report?
you can try this approach:
1) have before insert business rule on sys_email table; condition as specific to your report
2) query the incident table with the same condition which is used in report and then set the email body
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
11-05-2019 08:56 AM
One possible method would be to send an email with only the numeric values from the report - not the attachment. If a user wants the results in the subject line it sounds like they don't want to have to open an attachment - so why send one?
When I need to do this I include this code in a scheduled script that sends an email at the same time as the scheduled report. **this email includes a link to it.
while (grt.next()) {
if (***) {
add_ticket_to_list();
} else {
send_email();
tickets = [];
ticket_counter=0;
add_ticket_to_list();
}
}
send_email();
function send_email() {
var mail = new GlideEmailOutbound();
mail.addRecipient(email_address);
mail.setSubject('There are currently ' +tickets +' assigned to ' +team_name);
mail.setBody('Dear ' +manager_name +', ' +'<br>'
+'The list below shows tickets assigned to users in your team. ' +'<br>'
+'Please take the necessary steps to ensure these tickets are worked to completion.' +'<br>'
+'<br>'
+'Regards,' +'<br>'
+'Support Team' +'<br>'
+tickets
+'<br>'
+'<br>'
+'To see the full report, click the link below:' +'<br>'
+snow_link
);
mail.save();
}
function add_ticket_to_list() {
ticket_counter++;
tickets.push('<br>' +ticket_counter +'. ' +grt.getDisplayValue('number') +', assigned to ' + grt.getDisplayValue('assigned_to') +', Manager ' +grt.getDisplayValue('assigned_to.manager'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 11:44 PM
Hi Ayushi,
Did you get an answer to your question. Whether it worked? As our requirement is exactly the same what you have posted.
Regards,
Sofiya