Email Variable to track in Velocity | Community
Skip to main content
Level 5
May 18, 2020
Solved

Email Variable to track in Velocity

  • May 18, 2020
  • 1 reply
  • 4348 views

I have defined a variable within the email template and want to use that variable in velocity script. So, I am not sure about that email variable can be used in velocity or not?

 

Email Variable

Email variable name is email_variable
<meta class="mktoString" id="email_variable" mktoname="Button Link" default="mylink" mktomodulescope="true" />

 

Velocity Script code is

 

 

#if( $ObjectList.isEmpty() ) <a href="http://www.mywebsite.com?parameter=${email_variable}">read more</a> #end

 

 

 

Business Goal- To enable email local variable edit section in Email when variable is used in VTL coding.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Suggested method to use two velocity variable one in template level that will help to control the output but my purpose is to allow edit the variable value in email level as it offer when we create local variable in email template.

Although, velocity token can control output but not allow to edit variable at email level. To edit velocity variable value need to change the velocity token value each time which I want to avoid this limitations here.


Suggested method to use two velocity variable one in template level that will help to control the output but my purpose is to allow edit the variable value in email level as it offer when we create local variable in email template.

Although, velocity token can control output but not allow to edit variable at email level. To edit velocity variable value need to change the velocity token value each time which I want to avoid this limitations here.


It doesn't sound like you fully understood the setup.

 

The template would look like this:

 

{{my.beginConditionalOutputOrComment}} <a href="http://www.mywebsite.com?parameter=${email_variable}">read more</a> {{my.endConditionalOutputOrComment}}

 

 

  • The first Velocity token starts an #if condition
  • The second Velocity token #ends the #if condition.
  • So whether the variable is output is controlled by Velocity — controlled by whether the condition matches.
  • The value of the variable is still edited in the usual way.

This is actually a springboard to the much more advanced method I use myself, but you have to be an expert Velocity developer to implement and support that method in production. 

 

1 reply

SanfordWhiteman
Level 10
May 18, 2020

Sorry, variables can't be used in this way.

Level 5
May 19, 2020

Hi San,

May be my application is wrong. Could you please suggest possible way to achieve this business goal? or it has no options at all.

Jay
SanfordWhiteman
Level 10
May 19, 2020

You could have two Velocity {{my.tokens}} (one with the the #if and one with the #end) on either side of the variable in the template.

 

Velocity thus doesn't need to read the variable itself but still controls the output.