AnsweredAssumed Answered

Set URL variable from value found in string Velocity Script

Question asked by John Potter on Jul 30, 2019
Latest reply on Jul 31, 2019 by John Potter

I am trying to set a URL variable based on a specific value found within a string value from a Person Object. The Person Object field values are separated by a "|" character for example: |test1|test2|test3|. The Person Object is also checked in the tree on the right column of the Velocity Script modal window. I have tried using .contains and .matches using regex, but, I have not had much luck. Below is a sample of my Velocity Script, the IF statement never returns true when I know the lead I am testing contains the value I am comparing against. The ELSE statement is returned each and every time. The Email I am testing is being tested being sent as a "Person". What could I be doing wrong?:

## value looking form in string
#set( $stringVal = "test1" )

## check if the lead has above value
#if( $lead.personObject.matches("(\|)\s*${stringVal}\s*(\|)") )
     #set($browserURL = "www.exampleURL1.com")

## otherwise lead does not have above value
#else
     #set($browserURL = "www.exampleURL2.com")
#end

 

I have also tried:

## value looking for in string
#set ( $stringVal = $lead.personObject.split("|") )

## check if the lead has above value
#if($stringVal.contains("test1"))
     #set($browserURL = "www.exampleURL1.com")

## otherwise lead does not have above value
#else
     #set($browserURL = "www.exampleURL2.com")
#end

Thanks in advance.

Outcomes