Hi everyone!
I'm trying to create a velocity script that does the following.
If company name contains (starts with would also be helpful) "University" display the company name as "the University" otherwise display the current company name value.
In my beginner attempts I tried this but I'm obviously missing some critical steps.
#if (!$lead.Company.contains("university")())
#set ($companyName = "the ${lead.Company}")
#else
#set ($companyName = "${lead.Company}")
#end
${companyName}
Any suggestions/feedback is greatly appreciated!
Solved! Go to Solution.
Well, you have extra parentheses in there — so it's a fatal syntax error right away.
!$someString.contains means "not contains," which seems the reverse of what you said you want?
Also pretty sure you're expecting case-insenstitivity.
So more like
#if( $lead.Company.matches("(?i).*university.*") )
#set( $companyName = "the ${lead.Company}" )
#else
#set( $companyName = "${lead.Company}" )
#end
${companyName}
Well, you have extra parentheses in there — so it's a fatal syntax error right away.
!$someString.contains means "not contains," which seems the reverse of what you said you want?
Also pretty sure you're expecting case-insenstitivity.
So more like
#if( $lead.Company.matches("(?i).*university.*") )
#set( $companyName = "the ${lead.Company}" )
#else
#set( $companyName = "${lead.Company}" )
#end
${companyName}
Thank you! That was great. I got it to return "University of Kuali", my test records company name. But I can't get it to return "the University of Kuali" even though it matches the logic. Is there something else I might be missing?
Thanks again!
It outputs "the University of Kuali" for me when the Company is "University of Kuali".
Of course it'll also output "the The University of Kuali" if the Company is "The University of Kuali", but that's another matter. You probably need more robust logic than you were first thinking.
Crazy, must have just not refreshed the page as I thought with the email. It's working for me now too. I agree, I've created a secondary problem by solving the first haha. I appreciate you taking the time to respond, Sanford!