Multiple reports in Single email?

instance
Tera Contributor

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.?

15 REPLIES 15

 

in the Preview email it is showing the Same Data's with Different heading alone.

 

@instance  you want only one table?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@instance  The table on which the notification added is custom table?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

I want two tables. one table is Report of this one

 

Another table is report of this one

 

 

@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.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023