Re: Getting started with Velocity scripting

Phillip_Wild
Level 10

Hi all

I've got a couple of team members that I'd like to use more email scripting with Velocity. The problem is that they are marketers - and the Velocity documentation I've found so far isn't something very comprehensible for those who haven't used programming languages before. Is there something you know of that gives very simple examples of how to do different things in Velocity - and how to build a "programming mindset"?

If there is nothing specific to Velocity, even a general programming concepts document would be great. Thanks in advance.

15 REPLIES 15
Anonymous
Not applicable

Hi All,

I am definatly the type of person that learns form examples, it would be great if people share some great recepies, this demonstrates how it is done and also gives insitght into what is possible.

SanfordWhiteman
Level 10 - Community Moderator

Here's one from today:

Tokens and importing complex data

But I try not to overstate the ease of becoming truly fluent in Velocity. To do advanced Velocity, or to really understand what's going on in intermediate stuff like the example above, you need to grok Java objects, which is more than just "scripting."  (Velocity was designed as a somewhat cut-down Java VM, but still expected to be used primarily by Java developers, albeit junior ones. Think of it like a Java sandbox as opposed to a scripting language.)

Anonymous
Not applicable

Thanks Sanford,

If I have a score field and I want to display different text depending on a range how would I modify the below expression:

#if (${lead.example} == "> 500 : < 600") 

Text here

#end

BTW I made that up as an example

SanfordWhiteman
Level 10 - Community Moderator

Open a new thread and I'll tell ya.

Nicholas_Manojl
Level 9

Phillip - it helps if you start with a problem that needs solving.

For example, have your team figure out how to script up some text to display if they have a particular product versus another. Give them time for trial and error. Have them post on the community if they can't figure it out.

Use as much of the built in tools you can - for example, drag and drop a field name from the velocity editor into the textarea. It will take care of the formal notation for you.

Trust me, it's easier than you'd think once you allow your eyes to see past the curly braces and dollar signs.

Phillip_Wild
Level 10

Thanks everyone!

Yep, familiar with the Apache user guide Justin. Sanford's stuff is indeed excellent - but before now I had thought it might have been a bit too "teknkl" (sorry, couldn't help myself!) But Sanford, I am a subscriber ( I get the new post notifications anyway), so I might have a bit of a poke around to see whether there is some more introductory stuff. It's perfect for my level, but for my staff, they might need a gentler landing.

Sanford, it might be my inability to use your site properly....but is it possible to search for some of the more introductory posts? When I land on the website I can go back through posts chronologically, but I can't find anything that allows me to search for keywords in posts. For example, how would I find the "Code Anatomy" posts all under one tag?

SanfordWhiteman
Level 10 - Community Moderator

For example, how would I find the "Code Anatomy" posts all under one tag?

Like http://blog.teknkl.com/tag/code-anatomy

Phillip_Wild
Level 10

Perfect. Thanks!

Anonymous
Not applicable

Hi Phil,

I have the same problem 🙂  I actually found that the User Guide is not so bad, and was able to create a couple of simple scripts based on that. Let me know if you need help with anything specific, I may have templates for that.

SanfordWhiteman
Level 10 - Community Moderator

Hey Phillip,

Have you sent them to TEKNKL::Blog? (Thought you were subscribed yourself, but I don't see you right now.)

Not only is it the only place with accurate Velocity examples for Marketo (I must say) but in the Code Anatomy series of posts, I break down some "think like a programmer" concepts. Those posts are long, don't get me wrong, but I try to keep them beginner-friendly.

Grégoire_Miche2
Level 10

And BtW, Sanford Whiteman, is there a way to subscribe to your blog, excepted through the RSS Feed ?

SanfordWhiteman
Level 10 - Community Moderator

Sure, it should pop up a SumoMe form at the base of the page? Maybe you dismissed it?

Grégoire_Miche2
Level 10

HI again,

If I dismissed it, it was so long ago that I do not even remember having seen it

I cleansed the storage and reloaded, and it worked.

Thx.

-Greg

Grégoire_Miche2
Level 10

Sanford's blog is one of the most useful piece of documentation available around Marketo, I should say. I personally learnt a lot, and still learning a lot, reading it.

-Greg

Justin_Norris1
Level 10 - Champion Alumni

The official Velocity documentation provides the basics (this is likely what you've found already): Apache Velocity Engine - User Guide

There's nothing simpler out there that I've seen.

The only person publishing anything about Velocity that I know of is Mr. Sanford Whiteman​ - but his stuff is mainly more advanced use cases (although it is quite helpful for demonstrating what a programming mindset looks like).