- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:37 AM
How can I create a PDF of the content of the triggered email i.e. subject and body and attach it to the related record. Ex:- An email is triggered from an Incident record based on some conditions. Now, how can I capture that email in a PDF and attach it to the Incident record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:59 AM
Hello @Lokesh Pandey1 ,
What you can do is you can create a after Insert BR on sys_email table and you can pdf generator util like below to attach it to target record
var html = "<p>"+current.subject+"</p>" +"<br>"+current.body;// you can fetch html body to pass on to the pdf
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html, current.target_table, current.instance, 'My First PDF');
//body of pdf, table where you want to add the pdf, sys_id of the record where you want to add the generated pdf, name of file
;
action.setRedirect(current);
Hope this helps
Mark the answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:59 AM
Hello @Lokesh Pandey1 ,
What you can do is you can create a after Insert BR on sys_email table and you can pdf generator util like below to attach it to target record
var html = "<p>"+current.subject+"</p>" +"<br>"+current.body;// you can fetch html body to pass on to the pdf
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html, current.target_table, current.instance, 'My First PDF');
//body of pdf, table where you want to add the pdf, sys_id of the record where you want to add the generated pdf, name of file
;
action.setRedirect(current);
Hope this helps
Mark the answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 08:36 AM
Thanks a lot @Mohith Devatte .
This worked without any issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2025 11:30 PM
To Generate a PDF of the triggered EMAIL and attach it to the related record and also to email triggered
Create Before insert BR on sys_email table with script PFB
if (current.headers && current.headers.indexOf('Sys_id of notification') !== -1) { //sys of notification for which pdf needs to be generated
var html = "<p>" + current.subject + "</p>" + "<br>" + current.body;
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html, current.target_table, current.instance, 'My First PDF');
gs.log('Attach test' + result.attachment_id);
var attchmt = new GlideRecord('sys_attachment');
attchmt.addQuery('sys_id', result.attachment_id);
attchmt.query();
if (attchmt.next()) {
var attcontent = new GlideSysAttachment().getContentStream(attchmt.sys_id);
new GlideSysAttachment().writeContentStream(current, attchmt.getValue('file_name'), attchmt.getValue('content_type'), attcontent);
}
}
If you found this Information is useful, Please Accept as solution and hit like👍.
Thanks
Saqlain