Skip to main content
Level 4
October 22, 2013
Question

Velocity script doesn't work

  • October 22, 2013
  • 4 replies
  • 2035 views
Hello everyone!
I'm trying to use the Velocity template language in Marketo.
For example, I want to get all the people who live in Boston.

This is my simple Velocity script:



When I send a test message, then comes a blank message.

Who knows what's wrong?

Source:

#set ( $myLeadList = $complex.Objects.get("Lead") )
#foreach( $myResult in $myLeadList )
#if ( $myResult.City == "Boston" ) 
   <b>$myResult.Full_Name</b> lives in Boston <br />
 #end
#end


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

4 replies

October 23, 2013
Make sure the box is checked on the City attribute under the Standard Object->Lead object that you are referencing in your script.  Without the checkbox on the intended attribute, the values for a given object (like Lead.City) won't be able to be referenced.
Level 4
October 23, 2013
Travis, thank you for answer!
 
Yes, City and Full name are checked.

January 15, 2014
Did you ever figure this out?

I don't think that the full lead list is available to pass into a local variable to use/parse in a Velocity script.  If I understand what you're trying to do correctly, I think you're trying to access your entire lead database and output the names of the leads that are located in Boston?

In the context of generating an email to go to a lead, the field values associated with that specific lead are available as well as any objects that have records associated with that lead.

That said, I think there's a real need for more documentation from Marketo on how to reference the Marketo database in Velocity scripts.  If you (or anyone else reading this discussion) agree, could you "like" the following idea I just submitted?

https://community.marketo.com/MarketoIdeaDetail?id=08750000000JYPuAAO

Thanks,
-patrick
November 22, 2016

I need to second this question from Patrick, I have the same issue with an e-mail script of mine (the output of the e-mail token stays 'empty').

Has there been any solution to this?

SanfordWhiteman
Level 10
November 22, 2016

Please open a new thread instead of posting on this 3-year-old one and I'll answer there.  I'll also need to see your VTL code to see what you're doing.