SOLVED

Velocity Token Value pull in

Go to solution
freeza
Level 3

Hello,

How can I pull in the values from my Velocity Token. 

##check if HUG Event Choice is Chicago HUG
#if(${lead.HUG Event Choice} == "Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)")
#set($event.title = "Seattle UserTesting Hacks HUG Event")
#set($event.date = "Thursday, April 7th at 10 AM PT")
#set($event.destination = "<a href="https://usertesting.zoom.us/j/98148200405?pwd=K0d3SFFJWFpvY1FMN2RQWWMvSXkvUT09" style="color: #315CFD; text-decoration: underline;" target="_blank">Remotely via Zoom</a>")
##check if HUG Event Choice is London HUG

………….

#end

for something like this. In the email if I want the event.title

how can I pull that field into the email?

is it something similar to this? ${{my.HUGEventChoice_event.title}}

My token name is {{my.HUGEventChoice}}

3 ACCEPTED SOLUTIONS
Jo_Pitts1
Level 10 - Community Advisor

@freeza ,

getting out in front of the link question that'll be coming next.  Do it like this.  You don't need to replicate the styles, html etc. etc. etc.

 

#set( $allEventDetails = {
  "Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)" : {
    "title":"Seattle UserTesting Hacks HUG Event",
    "date":"Thursday, April 7th at 10 AM PT",
    "destination":"usertesting.zoom.us/j/98148200405?pwd=K0d3SFFJWFpvY1FMN2RQWWMvSXkvUT09"
  },
  "London HUG: UserTesting Hacks (4/12 2 pm GMT)" : {
    "title":"London UserTesting Hacks HUG Event",
    "date":"Tuesday, April 12th at 2 PM GMT",
    "destination":"usertesting.zoom.us/j/97207484508?pwd=dHRyakZ2c2orQ1FMM28vMk5aMU80QT09"
  },
  "Chicago HUG: UserTesting Hacks (4/19 10 am Central)" : {
    "title":"Chicago UserTesting Hacks HUG Event",
    "date":"Tuesday, April 19th at 10 AM CT",
    "destination":"usertesting.zoom.us/j/97012930463?pwd=d2h0TGc4cXZYaTJ2ZWdDUGpCNkUxdz09"
},
"Texas HUG: UserTesting Hacks (4/28 10 am Central)" : {
    "title":"Texas UserTesting Hacks HUG Event",
    "date":"Thursday, April 28th at 10 AM CT",
    "destination":"usertesting.zoom.us/j/94723137214?pwd=ZzZuNkZlWG1SM3M1VE80a3ZvdmZyUT09"
}
}
)
#set( $aEvent = $allEventDetails[$lead.hUGEventChoice]) 

<p>Title:${aEvent.title}</p>
<p><b>When:</b>${aEvent.when}</p>
<p><b>Where:</b><a href="https://${aEvent.where}" style="color: #315CFD; text-decoration: underline;" target="_blank">Remotely via Zoom</a></p>

 

That should be getting pretty close to what you need

View solution in original post

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

You will need to create a separate velocity token to do that (i.e. just display the title), add that token in the subject line and you should be good to go! You'll be able to reference data set in the variable in your original token!

View solution in original post

Jo_Pitts1
Level 10 - Community Advisor

Yep.  Just create a very simple token that has in it

${aEvent.title}

And pop that in the subject.  Fortunately, Marketo does the body processing before the subject line processing, so the variable is all nicely set for use.

View solution in original post

31 REPLIES 31
Jo_Pitts1
Level 10 - Community Advisor

@freeza 

OK.. so a shorter version of what I wrote before (to save @SanfordWhiteman from having to find and restore my earlier reply)

 

so, my first comment originally was for you to use the code highlighter, but I see that's happened.  

 

Then:

  1.  lead.HUG Event Choice isn't a valid field name in Velocity.  Drag and drop it from the RHS object tree to get the correct api/velocity friendly name
  2. Don't use {} around a variable unless you are wanting to display it.  And to that point, to write a Velocity variable out, simply go ${myVelocity Variable}
  3. Use .equals() instead of == (so your code should look like #if($myVar.equals("Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)")
  4. As a more strategic view, rather than having a massive and very repetitive list of if statements, take a look at this post.  It might provide you more of a direction to take with this piece of work https://nation.marketo.com/t5/product-discussions/email-script-token-shows-token-as-text/m-p/320763/...

Cheers

Jo

freeza
Level 3

Does this look good?

 

##check if HUG Event Choice is Seattle HUG
#if($(lead.hUGEventChoice.equals("Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)"))
#set($event.title = "Seattle UserTesting Hacks HUG Event")
#set($event.date = "Thursday, April 7th at 10 AM PT")
#set($event.destination = "<a href="https://usertesting.zoom.us/j/98148200405?pwd=K0d3SFFJWFpvY1FMN2RQWWMvSXkvUT09" style="color: #315CFD; text-decoration: underline;" target="_blank">Remotely via Zoom</a>")

........
#end

 

Jo_Pitts1
Level 10 - Community Advisor

@freeza 

Asides from the lack of syntax highlighting, there are many problems (syntax, and possibly business logic).

Let's step back.  What are you actually trying to do here.

Cheers

Jo

freeza
Level 3

I have this email content below is a screenshot. From the Velocity Token I have. I want the Event Title, When and Where to be generated according to the HUG Event the user choses. 

 

Jo_Pitts1
Level 10 - Community Advisor

So, the link I posted in an earlier reply is EXACTLY what you need with a few tiny tweaks

 

#set( $allEventDetails = {
  "Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)" : {
    "when":"The right date and time for Seattle",
    "where":"A link to your Seattle meeting - make sure and escape things like quotes"
  },
  "London HUG: Some Stuff about Hugs (4/7 10 am GMT)" : {
    "when":"The right date and time for London",
    "where":"A link to your London meeting - make sure and escape things like quotes"
  },
  "NZ Hug: It ain't all about the sheep" : {
    "when":"The right date and time for New Zealand",
    "where":"A link to your NZ meeting - make sure and escape things like quotes"
  }
}
)

#set( $aEvent = $allEventDetails[$lead.hUGEventChoice]) 

<p><b>When:</b>${aEvent.when}</p>
<p><b>Where:</b>${aEvent.where}</p>

 

Put all that in a velocity token... then, where you want the output, put in the {{my.whateverYourTokenIsCalled}}

My usual caveat applies.. I've not tested or debugged this.

Cheers

Jo

freeza
Level 3

So I have this,

But it keeps giving me an error. I attached the screenshot of the error I am getting.Screen Shot 2022-03-23 at 11.43.14 PM.png

 

 

 

 

This is how I am calling in the email

 

 

 

Jo_Pitts1
Level 10 - Community Advisor

OK.. Nothing happening here is good.

you can't have all those quotes in the link like that (hence why I said they needed escaping).

Also, look at what the code is doing.... the final output stage outputs

Title: aEvent.title

When: aEvent.when

Where: aEvent.where

you only need to call the token once.

Just make your links (for now) some thing simple like the word BOB.  

Then once you've got that working, I'll loop back to the links issue.

Jo_Pitts1
Level 10 - Community Advisor

@freeza ,

getting out in front of the link question that'll be coming next.  Do it like this.  You don't need to replicate the styles, html etc. etc. etc.

 

#set( $allEventDetails = {
  "Seattle HUG: UserTesting Hacks (4/7 10 am Pacific)" : {
    "title":"Seattle UserTesting Hacks HUG Event",
    "date":"Thursday, April 7th at 10 AM PT",
    "destination":"usertesting.zoom.us/j/98148200405?pwd=K0d3SFFJWFpvY1FMN2RQWWMvSXkvUT09"
  },
  "London HUG: UserTesting Hacks (4/12 2 pm GMT)" : {
    "title":"London UserTesting Hacks HUG Event",
    "date":"Tuesday, April 12th at 2 PM GMT",
    "destination":"usertesting.zoom.us/j/97207484508?pwd=dHRyakZ2c2orQ1FMM28vMk5aMU80QT09"
  },
  "Chicago HUG: UserTesting Hacks (4/19 10 am Central)" : {
    "title":"Chicago UserTesting Hacks HUG Event",
    "date":"Tuesday, April 19th at 10 AM CT",
    "destination":"usertesting.zoom.us/j/97012930463?pwd=d2h0TGc4cXZYaTJ2ZWdDUGpCNkUxdz09"
},
"Texas HUG: UserTesting Hacks (4/28 10 am Central)" : {
    "title":"Texas UserTesting Hacks HUG Event",
    "date":"Thursday, April 28th at 10 AM CT",
    "destination":"usertesting.zoom.us/j/94723137214?pwd=ZzZuNkZlWG1SM3M1VE80a3ZvdmZyUT09"
}
}
)
#set( $aEvent = $allEventDetails[$lead.hUGEventChoice]) 

<p>Title:${aEvent.title}</p>
<p><b>When:</b>${aEvent.when}</p>
<p><b>Where:</b><a href="https://${aEvent.where}" style="color: #315CFD; text-decoration: underline;" target="_blank">Remotely via Zoom</a></p>

 

That should be getting pretty close to what you need

WolframLotz
Level 4

Hi @Jo_Pitts1 

this is pretty cool stuff. And it worked mostly when I was testing it. 

What did not work for me was to request the title with 

 

${aEvent.title}

 

Instead I had to use something like this.

 

#set( $aEventTitle = $allEventDetails[$lead.hUGEventChoice]['title']) 

 

Is there anything I have to hold an eye on so I can use simply ${aEvent.title}?


Unfortunatly I was not able to get the JSON from a lead field. I assume the lead field delivers the JSON as string which is why I can't just lookup the key. Is this correct? 

Is there maybe some function like:

 

#set( $allEventDetails = convert.toObject($lead.allEventDetails))

 

Or is there another way I can get the mapping list out of a lead field? 

Kind regards
Wolfram

freeza
Level 3

I do have one more question. Is there any possibility we can get the event.title to show in the Subject Line of an email?

Jo_Pitts1
Level 10 - Community Advisor

Yep.  Just create a very simple token that has in it

${aEvent.title}

And pop that in the subject.  Fortunately, Marketo does the body processing before the subject line processing, so the variable is all nicely set for use.

freeza
Level 3

If I have a deigned Add to Calendar section in my email for Google, Outlook and IOS. Is there’s a way to change their invite links according to the event the user has signed up for? So right now the email updates the title, when and where but if I have a Add to Calendar section with 3 separate columns saying Google, Outlook and IOS. Is there’s a way to generate their invitation links dynamically?

 

 something like below 

 

F4FCA9E7-61BD-4315-BD76-A07427326908.jpeg

Jo_Pitts1
Level 10 - Community Advisor

@freeza ,

Add all the parameters for the event into the keymap (the way you added title).

Then use a link to agical (read all about it here https://blog.teknkl.com/introducing-agical-io-the-smarter-ics-file-generator/).  Essentially this is an extension of the logic used to create the zoom link.

 

I'm pretty certain you don't need a specific add to iOS option.   You just need GCAL (google) and ICS (everything else).  

 

Cheers

Jo

freeza
Level 3

If I have to send Reminder Emails for all of these events. Do I have to create Separate Smart Campaigns or else can I do everything in 1 Smart Campaign?

Since Each event is in different date.

Jo_Pitts1
Level 10 - Community Advisor

There are a few ways to skin that cat.

One would be to have a single smart campaign with all registrants in the audience, and wait steps to send each email on the right date (with a constraint to make sure the person was in that event).

The other is to set up <x> campaigns, one for each event, that is scheduled to fire <y> days before the event in question.

 

I'd probably go for the latter.  It's much clearer what is going on.

 

freeza
Level 3

Got it, thanks!

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

You can have additional parameters with the apt ics values (each for google/apple/outlook) for each of the HUG event in the velocity map  and use that in the calendar section of the email based on the HUG event type. Assuming you would have your original token with all the data above this token - you can have a token that can display the calendar section and dynamically add the apt ics links based on the HUG event type referencing the respective ics links  from the original token. You can also have a separate array locally defined in the velocity token - but IMO having all the info in a single array at one place in your original token wouldn’t hurt.

freeza
Level 3

Thanks!

freeza
Level 3

Great! Everything is working. Thank you guys!

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

You will need to create a separate velocity token to do that (i.e. just display the title), add that token in the subject line and you should be good to go! You'll be able to reference data set in the variable in your original token!