Is there a way to create a velocity email script token (is there a way to write a Velocity script) that can call on any other tokens, i.e. text my.tokens in the same program?
Velocity can access variables (VTL references) set in other Velocity {{my.tokens}} embedded in the same email asset (they don't technically have to be from the same program, they can be inherited).
It can't access text or other {{my.token}} types.
In Velocity-heavy environments it's common to create "data tokens" like so:
#set( $myVeloVar = "Some text" )
Then you can use that reference in other, later tokens:
$myVeloVar
There are even ways to embed data blocks without a literal #set statement but they're rather far afield.
Thank you for your response and knowledge!
shawn
Hey @Sanford, Thanks for your input here, but that's a bummer.
Program tokens inside an email script is my last resort. Do you know any other way to populate program tokens dynamically into an email?
EX. If X Field = X Value Display my.token1 Else if X field = Y Value Display my.token2
Any suggestions is greatly appreciated. Thanks! 🙂
Carl
If you don't consider segments an alternative, then conditional output is done w/Velocity... that's what it's there for!
Also, in case it isn't clear, you can have your output values in their own Velocity tokens, where they are managed exactly like text tokens:
Of course you would only do this to preserve the user experience of editing a token (since they can edit {{my.output1}} and {{my.output2}} here and can't mess anything else up). I try to avoid this method because VTL is verbose enough as it is.