Thanks! I removed the commas but am now getting a new error message:
Lexical error, Encountered: "m" (109), after : "." at *unset*[line 124, column 22] near
] )#foreach( $outputSet in $outputByCompany )#if( ${lead.Company}.matches($outputSet.pattern) )#set($matchedOutputSet = $outputSet)#break
I tried removing a bunch of spaces in that section since the only "m" after "." is in ${lead.Company}.matches, but there's no extra spaces between those terms and I'm not sure where else to look. Here's the script:
#set( $outputByCompany = [
{
"pattern" : "(?i)(.*)(^|,)\s*energysolutions|energysource|mhf services|energy solutions\s*(,|$)(.*)",
"speaker" : "goodbye"
},
{
"pattern" : "(?i)(.*)(^|,)\s*nuclear regulatory comm|nrc|usnrc\s*(,|$)(.*)",
"speaker" : "hello"
},
{
"pattern" : ".*",
"speaker" : "from ${lead.Company}"
}
] )
#foreach($outputSet in $outputByCompany)
#if(${lead.Company}.matches($outputSet.pattern))
#set($matchedOutputSet = $outputSet)
#break
#end
#end
${matchedOutputSet.speaker}
Explained in depth in this post: Velocity ${formal.notation} invites syntax errors: use it wisely
Yes! That did it!
Thank you for all of your assistance! The script is running perfectly now!
Hi Sandy,
I'm trying to get this script to work. I need a condition for if two choices are selected you get a different output:
Here is my code:
#set( $outputBysubscriptionFunction = [
{
"pattern" : "(?i).*\b(144322355954892&&187699601952849)\b.*",
"greeting" : "Choices 1 and 2"
},
{
"pattern" : "(?i).*\b(187699601952849)\b.*",
"greeting" : "Choice 1"
},
{
"pattern" : "(?i).*\b(144322355954892)\b.*",
"greeting" : "Choice 2"
}
] )
#foreach( $outputSet in $outputBysubscriptionFunction )
#if( $lead.NL_Subscriptions__c.matches($outputSet.pattern) )
#set( $matchedOutputSet = $outputSet )
#break
#end
#end
<span>${matchedOutputSet.greeting}</span>
The result I'm getting is Choice 2 for when two choices are selected. Am I close? What am I missing?
Pls move this to a new thread and I'll show you how it's done. You can refer back to this one. Better to separate distinct requirements, different correct answers.