AnsweredAssumed Answered

foreach in Velocity returns too much

Question asked by Robb Barrett Expert on Feb 28, 2014
Latest reply on Mar 5, 2014 by db5f05f47936ef937ae60e0cd901cbd52552064c
I'm trying to create a simple script in Velocity which will use the ZIP code provided by a person who fills out a form to assign a rep.  Ideally, it will run the ZIP through several arrays of postal codes to find the correct rep to assign. Here's an example of what I've written:

     #set( $robb = ["11111", "111", "111111"] )
     #set( $notrobb = ["1111111111", "1"])
      
     #foreach ($lead.PostalCode in $robb)
     Robb 
     #end
      
     #foreach ($lead.PostalCode in $notrobb)
     Not Robb 
          #end


     I put this in an alert email.  When I test, this is what I see in the email:

Rep Name:  Robb Robb Robb Not Robb Not Robb 

      

Outcomes