Hi All,
Can you confirm if we can use Email Script token in Email's From field? We have a case, where such token is used in email body, and it works fine however, we are unable to send test email, using other person field to populate data from this token when it is also used in From field.
Weird thing is that it works perefectly in Preview email option.
Can you please advise?
Thanks,
Kacper
Solved! Go to Solution.
Use a collection-centric approach here:
#set( $peopleBySession = {
"Sydney May 05|Sydney October 19" : "Person 1",
"Sydney June 06|Sydney July 17|Sydney August 19" : "Person 2",
".*Sydney.*" : "Person 3",
".*Munich.*" : "Person 4",
".*Warsaw.*" : "Person 5",
".*Madrid.*" : "Person 6",
".*" : "Some other persion"
} )
#foreach( $rule in $peopleBySession.entrySet() )
#if( $lead.session.matches($rule.getKey()) )
$rule.getValue()
#break
#end
#end
Also, remember (I seem to say this on every Velocity thread) you should not be using formal notation, let alone quoted formal notation, in simple #set statements.
This:
#set( $mainsession = "${lead.session}" )
should be this:
#set( $mainsession = $lead.session )
(Although you don't necessarily need an intermediate variable at all if you reduce repetition.)
It works fine.
You shouldn't be using Send Sample to test Velocity tokens. Use real emails only (this is noted all over past Nation posts).
Hi Sanford,
What do you mean by real email?
I tried sending that via Smart Campaign, still able to receive only those that do not have token in From field.
Any thoughts? Script may have some flaws?
Thanks,
Kacper
Script may have some flaws?
Certainly. The feature is supported so the error has to be elsewhere.
So we are trying to receive something as per below:
With above set up population in From field does not work.
It seems to be working with simplified logic:
Can you please validate what we are doing wrong? Any chance that we can achieve something closer to what you can see on the first screen?
We are assuming that we may have field mainsession with value Sydney only, so we need default logic for this part a well.
Thanks,
Kacper
Please don't post screenshots.
When posting code, highlight it using the Advanced Editor's syntax highlighter so it's readable and copyable.
Use a collection-centric approach here:
#set( $peopleBySession = {
"Sydney May 05|Sydney October 19" : "Person 1",
"Sydney June 06|Sydney July 17|Sydney August 19" : "Person 2",
".*Sydney.*" : "Person 3",
".*Munich.*" : "Person 4",
".*Warsaw.*" : "Person 5",
".*Madrid.*" : "Person 6",
".*" : "Some other persion"
} )
#foreach( $rule in $peopleBySession.entrySet() )
#if( $lead.session.matches($rule.getKey()) )
$rule.getValue()
#break
#end
#end
Also, remember (I seem to say this on every Velocity thread) you should not be using formal notation, let alone quoted formal notation, in simple #set statements.
This:
#set( $mainsession = "${lead.session}" )
should be this:
#set( $mainsession = $lead.session )
(Although you don't necessarily need an intermediate variable at all if you reduce repetition.)
Appreciate your help and sorry for print screens.
This works as expected!!
Can you clarify what these parts of function do?
Especially .entrySet, rule.getKey, rule.getValue?
#foreach( $rule in $peopleBySession.entrySet() )
#if( $lead.session.matches($rule.getKey()) )
$rule.getValue()
#break
#end
#end
Can you clarify what these parts of function do?
Especially .entrySet, rule.getKey, rule.getValue?
Sure.
$peopleBySession (declared with the {}) is a built-in Java object, an ordered map (LinkedHashMap) with key-value pairs. The keys and values, in this case, are both Strings, though the keys (left-hand-side) are used as regexp patterns (strings with specific meaning).
#foreach iterates over the map's .entrySet(), entry-by-entry (entry = a key-value pair).
.getKey() gets the current entry's String key (left-hand-side), .getValue() gets its String value (right-hand-side).