I was hoping to solve this problem with segmentation... but realized that I can't, if the user makes multiple choices. But I'm not finding Velocity syntax for what seems like it should be a simple thing:
If person's field contains "a" do "x" ... and a multiple, if contains "a" and "b" . I
This is based off a form with multiple choice checkboxes. That populates a string field with something like "000012; 000015" - if they've checked those two options.
I know ==, I've found ".contains" but I can't seem to figure out "!does NOT contain"
EDIT: I tried this - which didn't work at all, but probably gives a clear picture of what I'm trying to do:
#if ( index($lead.resourceChoice1, '0001' ) == 1) && ( index($lead.resourceChoice1, '0002' ) == -1)
#set($assettype = "Chose 1, but not 2 - content")
#elseif ( index($lead.resourceChoice1, '0001' ) == -1) && ( index($lead.resourceChoice1, '0002' ) == 1)
#set($assettype = "Chose 2, but not 1 - content")
#elseif ( index($lead.resourceChoice1, '0001' ) == 1) && ( index($lead.resourceChoice1, '0002' ) == 1)
#set($assettype = "Chose 1 & 2 - content")
#elseif ( index($lead.resourceChoice1, '0001' ) == -1) && ( index($lead.resourceChoice1, '0002' ) == -1)
#set($assettype = "Chose None - content")
#else
#set($assettype = "default content")
#end
##print it out
${assettype}
Solved! Go to Solution.
Can't just scan the whole string like that, you need to split it on the delimiter.
#set( $resourceChoices = $lead.resourceChoice1.split("; ") )
#if( $resourceChoices.contains("0001") & !$resourceChoices.contains("0002") )
does contain 0001, but not 0002
#end
etc.
Can't just scan the whole string like that, you need to split it on the delimiter.
#set( $resourceChoices = $lead.resourceChoice1.split("; ") )
#if( $resourceChoices.contains("0001") & !$resourceChoices.contains("0002") )
does contain 0001, but not 0002
#end
etc.
Awesome! That did the trick! I came across something like that, but it seemed like it was for creating an array - and I didn't think what I was doing above was an array.
Is that what I missed? ".contains" is for arrays? or maybe I'm just overthinkin' it?
I came across something like that, but it seemed like it was for creating an array
Yes, splitting a String into an ArrayList -- which is indeed what you want, since you want to treat the String as a collection of values.
".contains" is for arrays? or maybe I'm just overthinkin' it?
String.contains is for Strings, List.contains is for Lists. There's more than one contains method (an infinite number in Java as a whole!).