Re: opportunity tokens

Stephanie_Chmie
Level 2

I am new to opportunities. I send an introduction email to the outside partner who is working a lead. It currently pulls lead.tokens. I want it to either pull tokens from opportunities or contacts. Any advice on how or where to do this? 

Once the lead is converted I don't want it to pull info from the lead b/c it might be outdated. 

11 REPLIES 11
Stephanie_Chmie
Level 2

Ok so one more question. If the email I am sending is pulling info from the lead i.e. company name but 3 years later there is a new company name. I can't edit the lead so the email is still pulling the company name from the very first time they contacted us.  How can I fix this. I am not sure why this is so hard to do. I just need to reference things from the contact or the account in an email. 

SanfordWhiteman
Level 10 - Community Moderator

You use Velocity tokens to output Opportunity data (as you would with Custom Object data).

Stephanie_Chmie
Level 2

now for the stupid question.  What is and where do I find Velocity Script? 

Stephanie_Chmie
Level 2

Ok, nevermind that question, I have the script up but how/what do I add to it? 

SanfordWhiteman
Level 10 - Community Moderator

That's a very, very wide open question.

Script tokens are written in Velocity Template Language. I write extensively on tips and tricks for Velocity (see https://blog.teknkl.com/tag/velocity) but it's not not overnight thing. You're going to need to take some time to learn.

Stephanie_Chmie
Level 2

If Opportunities and Contacts are Marketo and they claim to have the best salesforce integration then why aren't the fields available for tokens like all of the lead fields are. 

SanfordWhiteman
Level 10 - Community Moderator

Everything you could possibly want to do with Opportunities (and with Salesforce COs), you can.

Remember that Opportunities are many-to-one (they're even more complex than that, given the Oppty Contact Role relationship). Therefore, there could never be a single token that represents "an" Oppty field, as because that field has different values across Oppty records. The syntax would have to change drastically beyond {{object.property}} -- in essence that extended syntax, and much more, is what you get w/Velocity.

Stephanie_Chmie
Level 2

So If I want to send an email with info on the contact associated with the lead how would I go about doing that? 

SanfordWhiteman
Level 10 - Community Moderator

"info on the contact associated with the lead" -- I don't understand.

Stephanie_Chmie
Level 2

sorry I want to send an email with the contact information of the primary contact associated with an opportunity. 

SanfordWhiteman
Level 10 - Community Moderator

This is more difficult than it seems.

You won't have the Role constraint available on a Opportunity is Updated trigger. That constraint exists only on the initial Added to Opportunity.

I can think of one approach: check in Velocity for the OCR (it will be visible there), and if the role is not primary, throw an error (this aborts the send). It's pretty brute-force, but should work.

You could also consider only exposing (using SFDC permissions) Opportunities in Marketo for the person who is primary. That way you'd always know you were in the right context. May not work for your case though.