Multiple reports in Single email?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 05:36 AM - edited 01-24-2023 02:14 AM
I have Created 3 reports.(Report A,ReportB,reportC).
and i have Written 3 different email script ( script a,b,c)to show the Result in the Table method .
How can i send these 3 different reports in the single email?
can you suggest me with your ideas.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:49 PM - edited 01-24-2023 09:09 PM
in the Preview email it is showing the Same Data's with Different heading alone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:50 PM
@instance you want only one table?
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:52 PM
@instance The table on which the notification added is custom table?
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:53 PM - edited 01-24-2023 09:10 PM
I want two tables. one table is Report of this one
Another table is report of this one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:58 PM
@instance Ok add the custom filters in the script.
As the current object is referring to only on record, you will not get the filter of other report.
So add encoded query like below
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
InactiveManagerinCostCentre();
noManagers();
function InactiveManagerinCostCentre() {
var inc = new GlideRecord(current.report.table);
inc.addEncodedQuery("manager.active=false");
inc.query();
if (inc.hasNext()) {
template.print('<br />');
template.print('<table style="height: 23px;" width="100%"><tbody><tr><td style="background-color: #0e5399;"><font color="#FFFFFF"><strong>P1/P2 :</strong></font></td></tr></tbody></table>');
var tbl = '<table style="height: 293px;" width="100%"><tbody>';
//template.print(tbl);
var tab = '<table style="width: 100%; border-collapse : collapse; " border = "2" cellpadding = "10"> <tbody>' + '<tr>' +
'<td style="background-color: #aeaeae;">' + '<b>Number</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Account Number</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Code</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Manager</b>' + '</td>' +
'</tr>';
template.print(tab);
}
while (inc.next()) {
var clsed = '<tr>' +
'<td>' + inc.name + '</td>' +
'<td>' + inc.account_number + '</td>' +
'<td>' + inc.code + '</td>' +
'<td>' + inc.manager.name + '</td>' +
'</tr>';
template.print(clsed);
}
var tab_end = '</tbody> </table>';
template.print(tab_end);
}
function noManagers() {
var inc = new GlideRecord(current.report.table);
inc.addEncodedQuery("managerISEMPTY");
inc.query();
if (inc.hasNext()) {
template.print('<br />');
template.print('<table style="height: 23px;" width="100%"><tbody><tr><td style="background-color: #0e5399;"><font color="#FFFFFF"><strong>Cost Centre With No Managers:</strong></font></td></tr></tbody></table>');
var tbl = '<table style="height: 293px;" width="100%"><tbody>';
//template.print(tbl);
var tab = '<table style="width: 100%; border-collapse : collapse; " border = "2" cellpadding = "10"> <tbody>' + '<tr>' +
'<td style="background-color: #aeaeae;">' + '<b>Number</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Account Number</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Code</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Manager</b>' + '</td>' +
'</tr>';
template.print(tab);
}
while (inc.next()) {
var clsed = '<tr>' +
'<td>' + inc.name + '</td>' +
'<td>' + inc.account_number + '</td>' +
'<td>' + inc.code + '</td>' +
'<td>' + inc.manager + '</td>' +
'</tr>';
template.print(clsed);
}
var tab_end = '</tbody> </table>';
template.print(tab_end);
}
})(current, template, email, email_action, event);
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023