Generate PDF as a formatted page and send email

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2011 08:21 PM
My goal is to have a easy way to take a record (It happens to be a Purchase Order record in a custom PO table) in ServiceNow and generate a formatted page (including image tags + other html formatting) and then generate a PDF file from that page and then send that PDF file to an email address
Step 1 - Generate a formatted page. I think the best way for this is a custom UI Page.
Step 2 - Create a PDF file for this page (similar to what happens when you export a page to PDF).
Step 3 - Send that PDF file in an email to an external vendor address that is contained on the original PO record in ServiceNow.
Ideally this would all be a one-click operation from the PO record.
Any thoughts or ideas how I could accomplish this requirement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2013 10:50 PM
I'm having the same requirements for a customer, is this possible ?
1) generate a pdf file
2) attach to a record
from a script
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2014 12:48 PM
Yes, I'm sure this is possible, as I've heard others are doing it. I also have this requirement. I understand their are some options such as using Office or Excel to pull in data, but really need to provide this feature for our staff. I'm getting more of these types of requests the more we use ServiceNow and especially when we add new custom applications. I certainly will share if I come across any information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2014 10:40 PM
I use this, but I dont think it works in dublin (havent tested yet) but im fairly confident it doesnt.
The problem is that the package removal tool cannot replace Packages.com.glide.generators.PDFGenerator() and packages cant be used anymore
function addAttachmentToEmail(sysEmailRec) {
try {
var targetTable = new String(sysEmailRec.target_table);
var targetSysId = new String(sysEmailRec.instance);
// Retrieve the record for the attached item
var targetRec = new GlideRecord(targetTable);
if (targetRec.get(targetSysId)) {
var pdfGenerator = new Packages.com.glide.generators.PDFGenerator();
pdfGenerator.setTarget(targetTable);
pdfGenerator.setSysID(targetSysId);
pdfGenerator.setList(false);
pdfGenerator.setDetails(true);
pdfGenerator.setLandscape(false);
var outStream = new Packages.java.io.ByteArrayOutputStream();
pdfGenerator.generate(outStream);
// Sys attachment creation
var sysAttachment = new Packages.com.glide.ui.SysAttachment();
var attID = sysAttachment.write(sysEmailRec, targetRec.getDisplayValue() + '.pdf', 'application/pdf', outStream.toByteArray());
}
} catch (ex) {
}
}
Ill post back if I workout how to change this to work in dublin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 10:38 PM
Hey Luke,
Did this work is later versions like eureka,Fuji,Geneva and Helsinki??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2014 02:04 PM
Hi Chris, did you ever get a resolution? I need something similar for a custom app. I was directed to:
Using PDFCrowd to generate a PDF file from ServiceNow.
I have no idea how to actually do it or use it but as I read, it will address your Step 2.
K