Sending opportunity-specific emails with ClickDimensions and CRM workflow

The Situation:

Recently we were challenged to find a solution for a client who want to trigger an email to be sent automatically to a specific contact when a “project” (a custom entity they use) met certain criteria. Triggering the send wasn’t really the issue as that can easily be accomplished via CRM workflow (as seen here). However, the same couldn’t be said for merging information from the “project” record into the email. As a contact could be related to multiple projects, and the relationship to contact was on the project record.

There were other business requirements and specific language that was used as well, but for clarity’s sake and to make it a bit more broadly applicable for everyone, I want to explain how this can be accomplished in terms of the default “opportunity” entity in CRM. We’ll pretend we are the admissions department of fictitious University that tacks prospective students under contacts, and uses the opportunity to track the applications and admissions process.

The Problem

Because CRM has a default “many to one” (N:1) relationship on opportunity tying it to a contact — meaning any given contact could be associated to multiple opportunities – the system doesn’t know which opportunity to retrieve information from, and the dynamic content engine which we use to process emails can’t iterate though child records to find specific information. And there is no direct path from the contact to the opportunity. Think of it in terms of using advanced find. You can tell advanced find to show you the opportunities where the contact is a certain contact, but if try to go the other way, you get stuck in this gray area of not knowing which child opportunity is returning.

The Solution

The solution was quite simple, and didn’t require any custom workflow assemblies or plugins. 🙂

Assumptions

In this example, when the opportunity is marked to qualify, it means that the student has requested an application, an admissions rep is now assigned to the opportunity, and a username and password has been provisioned for the prospective student in the Online Application System. The automatic welcome email, sent when the opportunity is marked to qualify, should contain information regarding the student (from contact) like the login information, name, etc… But because our university has separate applications for the separate schools, it is possible that a student will have multiple applications in the Application System. So we need to merge application-specific information into the email (from opportunity) like Primary Major Choice, Starting Semester, and Admissions Rep Info.

 

Plan

Use a custom field to be used by the workflow to send an email to the Contact on Opportunity, when the opportunity meets certain criteria, and also include information from that opportunity in the email.

The Trigger

The trigger was finite. (When an “Opportunity” has a sales stage of “Qualify,” then send the start the workflow.)

Customizations and Requirements

For this example, we only needed to add two new fields. Your process might be a little more complex or perhaps less.

Lookup to Opportunity on Contact: In order to create a direct path from the contact to the opportunity, we need to add a lookup to opportunity on the contact record.

Note: The value of this field will be automatically set and then cleared by a step in the workflow, so you don’t have to worry about any manual processes.

Send Welcome Email Checkbox (On Opportunity): In order tomake sure the welcome email is not sent multiple times, and to have easier reporting and insights, we added a checkbox on the opportunity to signify if the welcome email has been sent.

Note: Again, this will automatically be set by the workflow. No need for manual labor!

    The Email Template

The template we created was pretty basic, but needed to include the information from the opportunity in the workflow, so we use Freemarker to go from the recipient (contact) to the opportunity record through the custom lookup we added to the contact.

    

The Workflow Steps

Here’s the magic. To bring it all together and set it into motion, we need a three step workflow to set the lookup field on contact, send the email, then update the opportunity.

Step 1     Check to see if the opportunity is at Qualify and the “Sent Welcome Email” is set to “no”, then Update the Lookup on Contactto equal the this opportunity.

Step 2     Check to see if the lookup to opportunity equals this opportunity, and send a ClickDimensions email.

Step 3     Clear the Lookup on Contact, and update the “Sent Welcome Email” checkbox on opportunity.

Conclusion:

Because of the N:1 relationship, you can’t send emails with info from child opportunities or custom entities out of the box, but with a few slight enhancements and the power of CRM workflow the sky is the limit. Maybe you have a scenario where you can apply this. Let us know how you end up using it.

Powered by WPeMatico