In a previous role I ran a similar program to this and we used Email Scripting within tokens to populate email copy with data from the Opportunity object. We built a batch job in SFDC that flagged the opportunity at 90, 60, 30, and 0 days, and had corresponding smart campaigns in Marketo listening for that flag to change, which would then fire off the email to the primary contact on the opportunity. I wish I had some screenshots from this project to help, but it is a pretty straightforward project.
1 of 1 people found this helpful
By definition, you cannot set a trigger campaign on a date field since it does not change and there is no event you could trigger from. 2 ways to handle this:
- You can run a daily batch, as suggested by Ron above. This is the solution I would personally look for
- You can create a "Nb days to renewal" field in SFDC account and have an APEX batch process that updates this field daily. The field will sync with Marketo and creates Change Data Value activities in Marketo, that you will be able to use as triggers.
With regards to the email content, a Velocity script token will do the job. Pay attention to a couple of risks, though:
- You are depending on the opportunity contact role to be correctly filed out in SFDC. Unfortunately, you cannot leverage account opportunities.
- If a contact is linked to more than 10 opportunities, the Velocity script will not be able to process all of them (it is limited to 10 related records).
Hi Ron, Greg
Yes- I think the daily batch is pretty straight-forward and the direction I will go in.
In terms of the email content:
-Luckily, all of these types of opportunities will have the correct contact tagged as primary contact and the opportunities are not just simply tagged to an account
-Do you perhaps have some examples of some similar velocity scripting that I could take a look at to help me out?
I have tried to script a token for this (the first time I've tried this.) It would be to print the opportunity name of the opportunity which has a close date of 30 days away. Could you perhaps let me know what I am doing wrong?
#set( $defaultTimeZone = $ate.getTimeZone().getTimeZone("Europe/London") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $calConst = $field.in($calNow) )
## determine date 30 days from now
#set ($thirtyDaysAwayDate =$date.getFullYear()+($date.getMonth()+1)+$date.getDate()
##print date 30 days from now
#if( $OpportunityList && !$OpportunityList.isEmpty() )
#foreach( $opty in $sorter.sort($OpportunityList, "CloseDate") )
#if( $opty["CloseDate"] == $thirtyDaysAwayDate )
#set($myOpportunityName = $opty["Name"])
 There's a typo in the first line. You have
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Europe/London") )
 After you add 30 days to $calNow, you don't want to then output the original $date!
Also, you don't need to output individual date components,
#set( $thirtyDaysAwayDate =$date.getFullYear()+($date.getMonth()+1)+$date.getDate() )
#set( $thirtyDaysAwayDate = $date.format("yyyyMMdd",$calNow) )
 You're expecting the CloseDate to be stored as a yyyyMMdd string. Is that actually how it's stored on your objects? It should be yyyy-MM-dd in standard Date fields.
 Not sure why you're sorting the list. I know what the effect/benefit of sorting might be, but can you tell me exactly why you're sorting before doing the match?