Hi all,
I'm trying to create a script that says if a contact has an account owner of any of the stated emails (below), display html and if not display different html. However, when I try to test it, I get this error:
Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>Encountered ") \n" near</p> <div><pre >#if( $accountowner.matches($email) ) </pre><pre > #set($foundMatch) </pre><pre class="x-form-item-label"> #break </pre><pre >#if($foundMatch)</pre><pre >correct html</pre></div>
One of our front-end engineers had helped me with it but he isn't familiar with velocity so I'm not sure if it's just a simple syntax error. Any ideas?
#set ($accountowner = "${lead.Account_Owner_Email_Address}")
#set ($foundMatch = false)
#set( $outputByEmail = [
"test1@em.com",
"test2@em.com",
"test2@em.com",
"test4@em.com" ])
#foreach( $email in $outputByEmail )
#if( $accountowner.matches($email) )
#set($foundMatch)
#break
#if($foundMatch)
correct html
#else
defaulthtml
#end
You do have fundamental syntax errors.
However, the whole loop-and-break thing isn't necessary here. You're trying to find an exact match in a list. That's what List.contains is for.
Probably not a good idea to have a non-Velocity dev help you w/Velocity. It requires specialized knowledge.