Rich Dennis
Tera Expert
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-22-2018 11:22 AM
Scenario: A workflow email notification needs to include a PDF document.
- I've read several times that the best way to do this is via email notification by "Create Event" Activity, instead of the "Notification" Activity.
- Go to the Catalog Item that runs the Workflow and attach the PDF file to it.
- Register the new Event.
- Create an Email Notification:
-
- that will "Send when" [Event is fired]
- "Event parm 1 contains recipient" is checked.
- "Message HTML" has a mail script in it like ${mail_script:attach_file}
- Create a Notification Email Script that includes the following code:
// attach file var gr_sys_att = new GlideRecord('sys_attachment'); gr_sys_att.addQuery('file_name',"File_Name.pdf"); gr_sys_att.addQuery('table_name',"sc_cat_item"); gr_sys_att.addQuery('table_sys_id',"b7cffa9d4f58db8031a28b8d0210c75b"); // sys_id of the Catalog Item that the file was attached to earlier. gr_sys_att.query(); while (gr_sys_att.next()) { var content = new GlideSysAttachment().getContentStream(gr_sys_att.sys_id); new GlideSysAttachment().writeContentStream(current, gr_sys_att.getValue('file_name'), gr_sys_att.getValue('content_type'), content); }
- Note: I found through trial & error that this code block had to be before the last template.print() statement. If its not then the code never ran.
Dog Tax: This is Radley.