Re: Using Velocity script with an attribute that contains a space

Anonymous
Not applicable

Using Velocity script with an attribute that contains a space

This is an x-post from http://stackoverflow.com/q/33613463/197302 I will share anything I find between the two.

I am writing some Velocity Script as part of a Marketo email template that requires that I check if an boolean attribute on a lead is set or not.

When I attempt to display something associated with a lead in my system I can do something like;

{{lead.myName}}

This also works for fields that have spaces in them;

{{lead.my name}}

When it comes to using that field for #setting or #ifing something then it doesn't work as well.

#if($lead.my name) throws an error saying that an unexpected space has been found.

I have tried variants like #if(${lead.my name}) to no avail.

Any help / pointers would be massively helpful.

Actual use case

In my example the field I need to access is called lead.Subscribed to Innovation (L) 1, I don't think the brackets will cause a problem, certainly any error messages have been space related.

4 REPLIES 4
Anonymous
Not applicable

Re: Using Velocity script with an attribute that contains a space

Hi Toby,

In the Email Script editor have you tried dragging in the variable lead.Subscribed to Innovation (L) 1 from the right hand panel, under the Standard Objects > Lead object? Is the variable name from there any different?

Tim

Email Scripting » Marketo Developers

email script code

Anonymous
Not applicable

Re: Using Velocity script with an attribute that contains a space

Thanks Tim,

When moving it across it was a slightly different name (the API name), this wasn't actually working for me when I tried it initially. It was because I didn't check the field box.

D'oh, thanks for your help.

Justin_Cooperm2
Level 10

Re: Using Velocity script with an attribute that contains a space

Just drag it over as Tim mentioned. It will add the correct syntax for you. Generally, it just removes the spaces.

Also, keep in mind that you must make sure the field is checked on the right-hand pane anyway. Other way the value won't be available within your script.

Anonymous
Not applicable

Re: Using Velocity script with an attribute that contains a space

Thanks Justin, it was checking the box that did it!