generating PDF attachment and sending via email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
how to attach some PDF records in email notifications to senior management in risk management in ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RabindraK
Refer ServiceNow Documentation : Document attachments on an email notification
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RabindraK,
You can attach documents and reports to email notifications by scripting or linking to the sys ID of the record.
You can include all attachments from the source record with the notification. For example, if an incident update generates a notification, you can include all attachments from the incident record with the notification. To include all attachments from the source record, go to Advance view and select the check box for the Include attachments under What will it contain tab. The email messages, including attachments, cannot exceed the maximum email size. This size includes MIME encoding. For details on MIME encoding, see Email service size restrictions.
Attaching documents with scripting
Using scripting, you can attach documents by linking to them, or you can attach various types of reports by specifying their IDs in the system.
Linking to an attachment
You can add an attachment to a notification by linking to the attachment record in the message of the notification. Upon clicking the link, email recipients log in to the instance to view the attachment record.
template.print ( 'Attachment: <a href="/sys_attachment.do?sys_id=' + now_GR. sys_id + '">' + now_GR. file_name + '</a>\n ' ) ;
Attaching reports using the Sys ID
${report:X:Y}X is the type of report you want to attach (reportID, gaugeID, dashboardID, or chartID).
Y is the sys ID of the report, gauge, dashboard, or chart to be attached.
- ${report:reportID:<abc123>}
- ${report:gaugeID:<abc123>}
- ${report:dashboardID:<abc123>}
- ${report:chartID:<abc123>}
Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.
Kind Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RabindraK,
Yes, this is possible. If the PDF is already attached to the Risk record, you can configure your Email Notification to include record attachments so the PDF is sent automatically to senior management.
If the PDF needs to be generated dynamically, you can use Document Generation (or a Document Template) together with Flow Designer to generate the PDF, attach it to the Risk record, and then trigger the email notification with the generated PDF attached.
This approach keeps the process automated and ensures senior management receives the latest version of the report without any manual intervention.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @RabindraK ,
try this approach for generating pdf using template :
Use this script inside your server script auto-creates a sys_attachment record against current..
var pdfGenerator = new sn_communications.PDFGeneratorAPI();
var renderResult = pdfGenerator.convertUiPageToPDF(
'your_ui_page_name', // Jelly UI page defining the PDF layout
'sysparm_id',
current.sys_id,
current.getTableName()
);
Then attach this as a Mail Script under the notification's What it will contain
(function runMailScript(current, template, email, email_action, event) {
var att = new GlideRecord('sys_attachment');
att.addQuery('table_name', current.getTableName());
att.addQuery('table_sys_id', current.sys_id);
att.addQuery('content_type', 'application/pdf');
att.orderByDesc('sys_created_on');
att.setLimit(1);
att.query();
if (att.next()) {
email.addAttachment(att);
}
})(current, template, email, email_action, event);
If my response helped mark as helpful and accept the solution.