14 Replies Latest reply on Jan 4, 2018 11:00 PM by Sanford Whiteman

    Custom Token With Email Scripting

    Carley Donovan

      Hi Marketo Community,


      I am looking to build a custom token to do the following:

      I want to use the Nickname field if it is not empty, but if Nickname is empty I want to use the First Name field.

      I believe this can be achieved by using the velocity email scripting tool, and have come up with the following, which appears correct to me but is only populating First Name (and yes, I tested it on leads with the Nickname field as not empty).


      #if ("${lead.Nickname_c}" != "" )

        #set ($greeting = "Dear ${lead.FirstName},")


        #set ($greeting = "Dear ${lead.Nickname_c},")




      I have also tried using lead.Nickname_c.isEmpty and lead.Nickname_c.size = 0 as other options to check for empty field values. I did try null, even though it is technically not a null value if it is empty, which also did not work.


      I am not a developer by any stretch of the imagination so it is quite possible I am missing something or am completely off base.


      Thank you!