Customizing Your Email Messages with Velocity Templates CONFIDENTIAL Customizing Your Email Messages with Velocity Templates User Group Meeting October 21, 2015 Patrick Rose
Topics Why Custom Emails? What is Velocity? Email Settings CONFIDENTIAL Topics Why Custom Emails? What is Velocity? Email Settings Trigger Configuration Velocity Content Examples More Complex Examples
Why Custom Emails? Emails sent when conditions are met CONFIDENTIAL Why Custom Emails? Emails sent when conditions are met New or published data Updated data Data is a specific value Emails sent to specific users who start next business process or make decisions based on data Standard emails very generic in content and do not include specific data Custom emails include data, company-specific text, or formatting Custom emails require trigger and not in workflows
CONFIDENTIAL What is Velocity? Simplified language to reference objects in Java code Administrators customize dynamic content/outputs without access to main code base Contained within email messages, Velocity provides detailed items and quick links back to system Functional and attractive templates created by combining Velocity and HTML
Email Settings CONFIDENTIAL ***This requires a Tomcat restart in order to start working!***
Example Use Case Configuration does not require Message entity CONFIDENTIAL Example Use Case Sample Lot (Plasmid Lot) Request Email address attribute Trigger Impl (code that sends Email) Employee (Requestor) Configuration does not require Message entity
CONFIDENTIAL Setting Up Request
Your Turn Set up REQUEST Entity Type Requirements, include: CONFIDENTIAL Your Turn Set up REQUEST Entity Type Use REQUEST Super Type Requirements, include: Attribute to hold email address Association to Plasmid Lot Association to Employee
Trigger Configuration CONFIDENTIAL Trigger Configuration Take closer look at each attribute
CONFIDENTIAL Class Attributes Implementation Class and Trigger Type set by default to above values
CONFIDENTIAL Action Type Attribute Action Type tells trigger when to fire and send message Normal Action Types On_Create On_Update On_Publish
CONFIDENTIAL Traversal Attribute Use to send information from any Entity Types in message Allows for information to get to users without need to log to LIMS
Email Attribute Traversal must include “RECIPIENTS” variable CONFIDENTIAL Email Attribute Traversal must include “RECIPIENTS” variable Traversal tells email to go to Employee Association and send to their email address, designated in Email Address Attribute
CONFIDENTIAL External Emails You can email people outside of your organization as well You need to define an attribute that holds the external address in the Entity type In this case it is “Email Group”, you will only need to tell the trigger that the recipient is in this entity
Velocity Body Attribute CONFIDENTIAL Velocity Body Attribute
CONFIDENTIAL Velocity in the Email Each velocity statement should be designated as $REQUESTOR[0].name Since it can act like a list [#] is required Ability to go across entity types to show information
Common Variables Entity Object Available Variables Description CONFIDENTIAL Common Variables Entity Object Available Variables Description This Entity $this[0].name Get name of Entity type that trigger is on $this[0].barcode Get barcode of Entity type that trigger is on $this[0].getCreationDate() Get date created of Entity type that trigger is on $this[0].getPublishDate() Get date published of Entity type that trigger is on $this[0].getValue("attribute name") Get attribute on Entity type that trigger is on
Velocity in the Email Send link in text back to system CONFIDENTIAL Velocity in the Email Send link in text back to system Change second highlight to what you want it to say in email First highlight to be changed when you set it in your system
Your Turn Create new EMAILTRIGGER CONFIDENTIAL Your Turn Create new EMAILTRIGGER Add in traversal and Velocity body you would like to see in your email
CONFIDENTIAL Attaching the Trigger Go to your Request Super type and select triggers for your Entity type
CONFIDENTIAL Attaching the Trigger Pick your trigger under Action type you selected for email Add triggers in order you want them to fire
CONFIDENTIAL Final Email
CONFIDENTIAL More Complex Examples
CONFIDENTIAL Just More Velocity…
Getting Lot Information CONFIDENTIAL Getting Lot Information <table style="width: 500px; height: 82px;"> <thead> <tr style="vertical-align: top; font-size: 16px;"> <td><b><u>LOT ID</u></b></td> <td><b><u>Quantity to Send(mg)</u></b></td> </tr> </thead> <tbody> #foreach($data in $ExperimentSamples) <tr style="vertical-align: top; font-size: 14px;"> <td>$data.getValue("LOT")</td> <td>$data.getValue("Quantity to Send_ci")</td> #end </tbody> </table>
Tools HTML Cleaner- Makes your life easy! http://www.html-cleaner.com CONFIDENTIAL Tools HTML Cleaner- Makes your life easy! http://www.html-cleaner.com W3 School- Helps with HTML formatting tips http://www.w3schools.com/html/html_formatting.asp