hopefully a quick one. I'm just trying to find syntax somewhere for a little velocity script I have. Right now it's just a series of if/else statements. I'd like to include an or inside one of these. But I'm not really sure of the proper syntax for this.
Basically, I'd like to change this:
#elseif(${lead.lastRequestedAssetType} == "infographic")
Into something like this. I'm just assuming I might be close to the syntax:
#elseif(${lead.lastRequestedAssetType} == (“infographic" || “report”))
or maybe it's like this?
#elseif(${lead.lastRequestedAssetType} == "infographic" || “report”)
EDIT: Neither one of the above seems to have worked.
EDIT2: Figured it out. Just a little longer than I'd hoped:
#elseif((${lead.lastRequestedAssetType} == "white_paper") || (${lead.lastRequestedAssetType} == "report"))
Solved! Go to Solution.
You shouldn't be using ${formal} references here, but $simple (always use $simple in non-output situations, like comparisons).
There actually are shorter ways to express this condition.
One is to use a regex:
#if( $value.matches("^(apple|orange)$") )
Another is to use a collection, which can make for better code organization:
#set( $interestingValues = ["apple","orange"] )
#if( $interestingValues.contains($value) )
Finally, please remember to highlight code when posting.
You shouldn't be using ${formal} references here, but $simple (always use $simple in non-output situations, like comparisons).
There actually are shorter ways to express this condition.
One is to use a regex:
#if( $value.matches("^(apple|orange)$") )
Another is to use a collection, which can make for better code organization:
#set( $interestingValues = ["apple","orange"] )
#if( $interestingValues.contains($value) )
Finally, please remember to highlight code when posting.
Ah! Thank you! I never even noticed that that tool option. I've gone ahead and edited the first post to highlight code.
I'll try rewriting this now with the regex solution. Awesome!