Triggers based on SFDC opportunities

Anonymous
Not applicable

Triggers based on SFDC opportunities

Hi Marketo Community,

We have a renewal reminder program we would like to improve on:

A SFDC opportunity is created for each renewal opportunity.

The Opportunity Name relates to the contract number.

The Opportunity close date relates to the expiry of the existing contract.

We would like to better automate our renewal reminder process sending out emails 30days out, 60days out etc.

One contact might manage multiple contracts, therefore there could be multiple opportunities where this person is the primary contact for the opportunity.

  1. How would I trigger the correct reminder email to be sent out based on the opportunity close date, i.e 30days before opportunity close date, trigger to send contact 30day reminder email
  2. Is it possible to, based on the opportunity that is triggering the send, populate the email with the correlating opportunity name (i.e contract number) so that the contact is aware of which contract we are reminding them about

Thanks in advance for any advice,

Mieke

7 REPLIES 7
Ron_Yeager2
Level 1

Re: Triggers based on SFDC opportunities

Hi Mieke,

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.

Ron

Grégoire_Miche2
Level 10

Re: Triggers based on SFDC opportunities

Hi Mieke,

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:

  1. You can run a daily batch, as suggested by Ron above. This is the solution I would personally look for
  2. 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).

-Greg

Grégoire_Miche2
Level 10

Re: Triggers based on SFDC opportunities

and vote here:

Anonymous
Not applicable

Re: Triggers based on SFDC opportunities

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?

Thanks,
Mieke

Anonymous
Not applicable

Re: Triggers based on SFDC opportunities

Hi Grégoire,

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

$calNow.add($calConst.DATE,30)

#set ($thirtyDaysAwayDate =$date.getFullYear()+($date.getMonth()+1)+$date.getDate()

))

##print date 30 days from now

${thirtyDaysAwayDate}

#if( $OpportunityList && !$OpportunityList.isEmpty() )

#foreach( $opty in $sorter.sort($OpportunityList, "CloseDate") ) 

#if( $opty["CloseDate"] == $thirtyDaysAwayDate ) 

#set($myOpportunityName = $opty["Name"])

#end

#end

##print myOpportunityName

${myOpportunityName}

#end

Thanks,

Mieke

SanfordWhiteman
Level 10 - Community Moderator

Re: Triggers based on SFDC opportunities

[1] There's a typo in the first line. You have

  ate

instead of

  date

Should be

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Europe/London") )

[2]  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,

Instead of:

#set( $thirtyDaysAwayDate =$date.getFullYear()+($date.getMonth()+1)+$date.getDate() )

Use:

#set( $thirtyDaysAwayDate = $date.format("yyyyMMdd",$calNow) )

[3] 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.

[4] 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?

SanfordWhiteman
Level 10 - Community Moderator

Re: Triggers based on SFDC opportunities

Mieke, when posting code, please use the Syntax Highlighter in Advanced Editor:

pastedImage_2.png