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 04:30 PM
@Ankur Bawiskar How to write 3 logics to print data from those 3 individual reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 06:39 PM - edited 01-24-2023 09:09 PM
can you help me in Joining this in to a Single Email script .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 08:28 PM - edited 01-24-2023 09:09 PM
any suggestions i need these 2 email script to join as a single email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:02 PM
I already mentioned above to combine the scripts in single email script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 10:43 PM
@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.
ServiceNow Community Rising Star, Class of 2023