Velocity Token Value pull in | Community
Skip to main content
Level 3
March 23, 2022
Solved

Velocity Token Value pull in

  • March 23, 2022
  • 2 replies
  • 5607 views

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}}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jo_Pitts1

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.


@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

2 replies

Jo_Pitts1
Community Advisor
Community Advisor
March 24, 2022

I wrote a really long reply to this when it was in the wrong board.

Now I can't find it.

 

@freeza , did you delete your original, and re-create it in the product discussion board?

SanfordWhiteman
Level 10
March 24, 2022

@jo_pitts1 wrote:

I wrote a really long reply to this when it was in the wrong board.

Now I can't find it.

 

@freeza , did you delete your original, and re-create it in the product discussion board?


Jo, I moved it, but your response wasn’t there (anymore) even on the other board. I’ll see if I can restore it.

Jo_Pitts1
Community Advisor
Community Advisor
March 24, 2022

Thanks.  It covered (I think) most of the things you'd have raised 🙂

Jo_Pitts1
Community Advisor
Community Advisor
March 24, 2022

@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/highlight/true#M181161

Cheers

Jo

freezaAuthor
Level 3
March 24, 2022

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

 

SanfordWhiteman
Level 10
March 24, 2022

Please use the syntax highlighter so it's readable, thanks.