Advanced My Tokens: Apache Velocity and Null checking

Anonymous
Not applicable

Advanced My Tokens: Apache Velocity and Null checking

Hey guys, i'm getting started with Velocity and am trying to check if a record in Salesforce's Name is blank, and do some logic.

I've solved this by switching the null check to $foo != "" but I'm still interested to see what you guys know about Nulls in Marketo's implementation of Velocitybecause the information I've seen online is sporadic, I'm going to encounter it later, and the stuff I've played with below threw a minimalistic error:
 
#set( $foo = ${lead.FirstName} )

#if ($foo != null)
  Hello $foo!
#else
  Hello Unknown Person!
#end

When sending test email:
User-added image
Tags (1)
2 REPLIES 2
Anonymous
Not applicable

Re: Advanced My Tokens: Apache Velocity and Null checking

I am guessing you are seeing this error because FirstName does not return anything if there is no value.

Here's how I would implement this. Let me know what you think? 

#set( $foo = ${lead.FirstName} )
#set( $blank = "" )

#if ($foo == $blank)
  Hello Unknown Person!
#else
  Hello $foo
#end
Anonymous
Not applicable

Re: Advanced My Tokens: Apache Velocity and Null checking

I was more after how (and if) nulls are handled in Velocity/Marketo. In the last 10 minutes I think I've read that null isn't supported in Velocity, but if you import a bunch of Java that isn't used by Velocity you can enable them.

Maybe I'm not thinking about it right: Do nulls get pulled from SFDC or does it only ever get empty strings?