I have a client who wants to track all outgoing messaging from all of their K2 applications to assist in troubleshooting if someone says they didn’t receive a notification.
Normally, no big deal; create a database table or two, a database view and an insert and a list proc, turn those procs into methods in a SmO and call it from a SmartObject event after each of the email events in the workflow. Good to go, right?
But all outgoing messaging includes escalation e-mails… trickier, but I’ve got a slick little trick up my sleeve.
How to track message metadata from an escalation email? Why, call your SmartObject method from the message body, of course!
In a typical workflow scenario, you might add an E-mail Event to an activity when an action is completed. So recording that message for tracking later is as easy as copying the addressees, subject line, and so forth into a subsequent SmartObject call. But escalations work differently — if you choose to use an email escalation, you’re presented the familiar E-mail Event wizard, but there’s no way to add an event to follow it.
BUT embedding a SmartObject method call inside of the message body in the wizard will achieve the same result for you without the need for a subsequent event.
K2 will execute the SmartObject method when the email event fires in the workflow. As long as no value is returned to the body of the message, nobody will be the wiser — and that metadata you want to track will be safe and secure inside your database before the actual message takes flight!