Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

@Ankur Bawiskar How to write 3 logics to print data from those 3 individual reports

 

can you help me in Joining this in to a Single Email script .

 

 

 

any suggestions i need these 2 email script to join as a single email script

@instance  

I already mentioned above to combine the scripts in single email script

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@instance  Just add both functions in same mail script. 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(current.report.filter);
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(current.report.filter);
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