I am trying to create a token that generates values based off a field called Preferred Location. Below is the velocity I am using.
#if(${lead.preferredLocation} = "Brea")
<p style="padding: 0; margin: 0;text-align: center;font-weight: bold;">BREA</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">375 W. Birch Street Suite 1-A</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">Brea, CA 92821</p>
#end
I dropped the token in the email and when I go to preview the email I receive this message. What is wrong here?
Solved! Go to Solution.
You meant to use the double-equals sign but used single-equals instead.
But actually you shouldn't use double-equals, either. Use the String.equals() method as it has fewer unexpected behaviors. And also use $simple references inside directives, not ${formal} references.
#if( $lead.preferredLocation.equals("Brea") )
<p style="padding: 0; margin: 0;text-align: center;font-weight: bold;">BREA</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">375 W. Birch Street Suite 1-A</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">Brea, CA 92821</p>
#end
You meant to use the double-equals sign but used single-equals instead.
But actually you shouldn't use double-equals, either. Use the String.equals() method as it has fewer unexpected behaviors. And also use $simple references inside directives, not ${formal} references.
#if( $lead.preferredLocation.equals("Brea") )
<p style="padding: 0; margin: 0;text-align: center;font-weight: bold;">BREA</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">375 W. Birch Street Suite 1-A</p>
<span class="Georgia, Times, "Times New Roman", serif;"></span>
<p style="padding: 0; margin: 0;text-align: center;">Brea, CA 92821</p>
#end