Skip to main content
Sherry_Wang
Level 1
May 16, 2016
Question

if (${}=="") && (${}=="") statement

  • May 16, 2016
  • 3 replies
  • 1774 views

Dear fellow Marketo users,

I am trying to write a script for a "if A and B" statement, meaning two variables in "if statement" instead of just one variable. I researched on the Apache Velocity script site, and found "&&" should be used between two variables. So my script writes as below:

#if(${A} =="xx") && (${B} == "xx")

#set ($xx = "xx")

#elseif (${A} == "xx") && (${B} == "xx")

#set ($xx="xx")

#else

#set($xx = "default")

#end

is there any error in my script? I don't seem to get the result i want, but when i use lead to test it, it shows the default, no error alert..

Any help is appreciated!!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

May 23, 2016

How are you testing it?

Are you 'previewing' the email for the test lead?

or

actually sending the email in a smart campaign to that test lead?

The first way does not correctly test velocity scripts. You have to 'actually launch' a smart campaign to test it.

Please feel free to reach out if you need help.

Rajesh

May 23, 2016

@Sherry Wang​

Just because this is a common error: If ${A} is lead or custom object you have to tick its box in the right hand navigation pane. Otherwise the script won't work.

May 23, 2016

You might want to try writing it up where the criteria is all inside the parentheses for the if statement. Here's an example of a line with the && criteria:

#if ($xDaysAgo < $marginErrorUp && $xDaysAgo > $marginErrorDown)