SOLVED

Including tokens in a velocity script

Go to solution
Basel_Kirmani
Level 2

Including tokens in a velocity script

Hi! I hope I'm asking this in the correct place.

 

I am running an email campaign where if a lead has an agent, a portion of the email (it's an entire section with images) saying "your agent is X and their details are Y" is displayed. But if a lead does not have an agent, I want to exclude that section entirely (rather than display an empty section with blank fields).

 

I have got as far as drafting the velocity script below, which uses an #if statement to check if the lead has an agent, and outputting that entire table section only if the lead's agent is not blank (we use W99999 to indicate that a client has not been assigned an agent yet). But the tokens e.g {{lead.Name of servicing agent:default=Financial Planning Manager’s Name}} in the bottom part of the code don't render properly - the recipients see the squiggly brackets and the text lead.Name of servicing agent:default=Financial Planning Manager’s Name instead of their agent's name.

 

May I please ask if anyone knows a way to have a velocity script which checks a field value, and includes tokenized values as part of the output? Thanks!

 

#if( ${lead.agent}!= "W99999")

              <tbody> 
                <tr width="100%"> 
                  <td class="module"> 
                    <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
                      <tbody> 
                        <tr width="100%"> 
                          <td width="40" class="">&nbsp;</td> 
                          <td style="width: 560px"> 
                            <table border="0" cellpadding="0" cellspacing="0" class="column" style="padding: 0 49px 0 49px; display:table;" width="560"> 
                              <tbody> 
                                <tr valign="top"> 
                                  <td width="100%"> 
                                    <table align="left" border="0" cellpadding="0" cellspacing="0" class="col-5" style="height:100%; display:table-cell;"> 
                                      <tbody> 
                                        <tr valign="top"> 
                                          <td> 
                                            <table border="0" cellpadding="0" cellspacing="0"> 
                                              <tbody> 
                                                <tr> 
                                                  <td> 
                                                    <table border="0" cellpadding="0" cellspacing="0"> 
                                                      <tbody> 
                                                        <tr> 
                                                          <td valign="top" width="80"><img class="mktoImg" id="iconimg41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" align="top" src="https://asia.manulifeam.com/rs/819-VRX-399/images/callicon.png" width="50" style="width:50px; height:50px;" height="50" mktoname="Icon" mktolockimgsize="true" /></td> 
                                                          <td valign="middle" style="font-family:arial; text-align:left; font-size:16px; line-height:26px; color:#282B3E;" class="mktEditable" id="iconmodtxt41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" mktoname="Icon Module Text"> 
                                                            <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> 
                                                              <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                                                                <span style="color: #00a758; font-family: arial, helvetica, sans-serif; font-size: 16px;"><strong><span style="font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; float: none; display: inline !important;">Contact your Manulife Financial Planning Manager</span></strong></span>
                                                              </div> 
                                                              <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                                                                <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Want to learn more about our investment strategies? Please contact your Financial Planning Manager.&nbsp;</span>
                                                              </div> 
                                                              <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                                                                <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;"><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; 
font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">You can also click<span>&nbsp;</span></span><a href="https://www.manulifefunds.com.hk/en/investchoice/contact-us.html" target="_blank" style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">here</a><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span>&nbsp;</span>to contact with us.</span></span>
                                                              </div> 
                                                              <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                                                                <span style="font-size: 16px; font-family: arial, helvetica, sans-serif;"><strong style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; 
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #282b3e; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; 
text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Your Financial Planning Manager : {{lead.Name of servicing agent:default=Financial Planning Manager’s Name}}<br />T : {{lead.Phone of servicing agent:default=Mobile No}}<br />E :&nbsp;{{lead.Manulife Agent Email:default=Financial Planning Manager’s Email}}</span></strong></span>
                                                              </div> 
                                                            </div> </td> 
                                                        </tr> 
                                                        <tr> 
                                                          <td colspan="2">&nbsp;</td> 
                                                        </tr> 
                                                      </tbody> 
                                                    </table> </td> 
                                                </tr> 
                                              </tbody> 
                                            </table> </td> 
                                        </tr> 
                                      </tbody> 
                                    </table> </td> 
                                </tr> 
                              </tbody> 
                            </table> </td> 
                          <td class="" style="width: 40px">&nbsp;</td> 
                        </tr> 
                      </tbody> 
                    </table> </td> 
                </tr> 
              </tbody> 
              
 #end             

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor

Re: Including tokens in a velocity script

Well, you cannot reference the regular email tokens directly as they are being used in the Email asset - you need to reference the fields as per the velocity construct (using the "$" character). Check out this documentation page that has some good beginner examples that you can refer. 

 

You'll also need an if-else construct for each field to set the default values in the case the field value is empty. Below is the script that you can refer, be sure to switch the field names in the below script with the right field names (you can pull the correct field names by pulling the respective fields from the object selector tree in right pane in the email script token). Also ensure that all the fields that you use in the email script token are check marked in the object selector tree, without that the fields' data would not be available to the velocity.

 

 

#if(!$lead.agent.equals("W99999"))

#if( $lead.Nameofservicingagent.isEmpty() ) ##update the correct lead field name
#set($serviceAgentName = "Financial Planning Manager’s Name") ##set the default value if the Name of servicing agent field is empty
#else
#set($serviceAgentName = $lead.Nameofservicingagent) ##update the correct lead field name
#end

#if( $lead.Phoneofservicingagent.isEmpty() ) ##update the correct lead field name
#set($serviceAgentPhone = "Mobile No") ##set the default value if Phone of servicing agent field is empty
#else
#set($serviceAgentPhone = $lead.Phoneofservicingagent) ##update the correct lead field name
#end

#if( $lead.ManulifeAgentEmail.isEmpty()) ##update the correct lead field name
#set($financialPlanManagerEmail = "Mobile No") ##set the default value if Manulife Agent Email field is empty
#else
#set($financialPlanManagerEmail = $lead.ManulifeAgentEmail) ##update the correct lead field name
#end


 <tbody> 
 <tr width="100%"> 
 <td class="module"> 
 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
 <tbody> 
 <tr width="100%"> 
 <td width="40" class="">&nbsp;</td> 
 <td style="width: 560px"> 
 <table border="0" cellpadding="0" cellspacing="0" class="column" style="padding: 0 49px 0 49px; display:table;" width="560"> 
 <tbody> 
 <tr valign="top"> 
 <td width="100%"> 
 <table align="left" border="0" cellpadding="0" cellspacing="0" class="col-5" style="height:100%; display:table-cell;"> 
 <tbody> 
 <tr valign="top"> 
 <td> 
 <table border="0" cellpadding="0" cellspacing="0"> 
 <tbody> 
 <tr> 
 <td> 
 <table border="0" cellpadding="0" cellspacing="0"> 
 <tbody> 
 <tr> 
 <td valign="top" width="80"><img class="mktoImg" id="iconimg41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" align="top" src="https://asia.manulifeam.com/rs/819-VRX-399/images/callicon.png" width="50" style="width:50px; height:50px;" height="50" mktoname="Icon" mktolockimgsize="true" /></td> 
 <td valign="middle" style="font-family:arial; text-align:left; font-size:16px; line-height:26px; color:#282B3E;" class="mktEditable" id="iconmodtxt41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" mktoname="Icon Module Text"> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #00a758; font-family: arial, helvetica, sans-serif; font-size: 16px;"><strong><span style="font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; float: none; display: inline !important;">Contact your Manulife Financial Planning Manager</span></strong></span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Want to learn more about our investment strategies? Please contact your Financial Planning Manager.&nbsp;</span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;"><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; 
font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">You can also click<span>&nbsp;</span></span><a href="https://www.manulifefunds.com.hk/en/investchoice/contact-us.html" target="_blank" style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">here</a><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span>&nbsp;</span>to contact with us.</span></span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="font-size: 16px; font-family: arial, helvetica, sans-serif;"><strong style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; 
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #282b3e; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; 
text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Your Financial Planning Manager : $serviceAgentName<br />T : $serviceAgentPhone<br />E :&nbsp;$financialPlanManagerEmail</span></strong></span>
 </div> 
 </div> </td> 
 </tr> 
 <tr> 
 <td colspan="2">&nbsp;</td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 <td class="" style="width: 40px">&nbsp;</td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 
 #end 

 

Best,
Darshil

View solution in original post

10 REPLIES 10
Darshil_Shah1
Level 10 - Community Advisor

Re: Including tokens in a velocity script

Well, you cannot reference the regular email tokens directly as they are being used in the Email asset - you need to reference the fields as per the velocity construct (using the "$" character). Check out this documentation page that has some good beginner examples that you can refer. 

 

You'll also need an if-else construct for each field to set the default values in the case the field value is empty. Below is the script that you can refer, be sure to switch the field names in the below script with the right field names (you can pull the correct field names by pulling the respective fields from the object selector tree in right pane in the email script token). Also ensure that all the fields that you use in the email script token are check marked in the object selector tree, without that the fields' data would not be available to the velocity.

 

 

#if(!$lead.agent.equals("W99999"))

#if( $lead.Nameofservicingagent.isEmpty() ) ##update the correct lead field name
#set($serviceAgentName = "Financial Planning Manager’s Name") ##set the default value if the Name of servicing agent field is empty
#else
#set($serviceAgentName = $lead.Nameofservicingagent) ##update the correct lead field name
#end

#if( $lead.Phoneofservicingagent.isEmpty() ) ##update the correct lead field name
#set($serviceAgentPhone = "Mobile No") ##set the default value if Phone of servicing agent field is empty
#else
#set($serviceAgentPhone = $lead.Phoneofservicingagent) ##update the correct lead field name
#end

#if( $lead.ManulifeAgentEmail.isEmpty()) ##update the correct lead field name
#set($financialPlanManagerEmail = "Mobile No") ##set the default value if Manulife Agent Email field is empty
#else
#set($financialPlanManagerEmail = $lead.ManulifeAgentEmail) ##update the correct lead field name
#end


 <tbody> 
 <tr width="100%"> 
 <td class="module"> 
 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
 <tbody> 
 <tr width="100%"> 
 <td width="40" class="">&nbsp;</td> 
 <td style="width: 560px"> 
 <table border="0" cellpadding="0" cellspacing="0" class="column" style="padding: 0 49px 0 49px; display:table;" width="560"> 
 <tbody> 
 <tr valign="top"> 
 <td width="100%"> 
 <table align="left" border="0" cellpadding="0" cellspacing="0" class="col-5" style="height:100%; display:table-cell;"> 
 <tbody> 
 <tr valign="top"> 
 <td> 
 <table border="0" cellpadding="0" cellspacing="0"> 
 <tbody> 
 <tr> 
 <td> 
 <table border="0" cellpadding="0" cellspacing="0"> 
 <tbody> 
 <tr> 
 <td valign="top" width="80"><img class="mktoImg" id="iconimg41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" align="top" src="https://asia.manulifeam.com/rs/819-VRX-399/images/callicon.png" width="50" style="width:50px; height:50px;" height="50" mktoname="Icon" mktolockimgsize="true" /></td> 
 <td valign="middle" style="font-family:arial; text-align:left; font-size:16px; line-height:26px; color:#282B3E;" class="mktEditable" id="iconmodtxt41bb4479-a6ca-403a-ace9-5efd779b3ecabf1270c5-1bdb-46d5-96a3-cafa6834b89b" mktoname="Icon Module Text"> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #00a758; font-family: arial, helvetica, sans-serif; font-size: 16px;"><strong><span style="font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; float: none; display: inline !important;">Contact your Manulife Financial Planning Manager</span></strong></span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Want to learn more about our investment strategies? Please contact your Financial Planning Manager.&nbsp;</span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; 
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;"><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; 
font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">You can also click<span>&nbsp;</span></span><a href="https://www.manulifefunds.com.hk/en/investchoice/contact-us.html" target="_blank" style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">here</a><span style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: 
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span>&nbsp;</span>to contact with us.</span></span>
 </div> 
 <div style="color: #282b3e; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; 
text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
 <span style="font-size: 16px; font-family: arial, helvetica, sans-serif;"><strong style="color: #282b3e; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; 
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #282b3e; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; 
text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Your Financial Planning Manager : $serviceAgentName<br />T : $serviceAgentPhone<br />E :&nbsp;$financialPlanManagerEmail</span></strong></span>
 </div> 
 </div> </td> 
 </tr> 
 <tr> 
 <td colspan="2">&nbsp;</td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 </table> </td> 
 <td class="" style="width: 40px">&nbsp;</td> 
 </tr> 
 </tbody> 
 </table> </td> 
 </tr> 
 </tbody> 
 
 #end 

 

Best,
Darshil
SanfordWhiteman
Level 10 - Community Moderator

Re: Including tokens in a velocity script

To output default values for arbitrary fields (somewhat like the {{lead.token:default=}} syntax, though much more robust) you can also look into the approach here:

Streamline your script tokens with a #displayIfFilled Velocimacro

Basel_Kirmani
Level 2

Re: Including tokens in a velocity script

Thank you Darshil! Sorry, I haven't had a chance to try out your solution yet, but just wanted to post a thank you for taking the time so far. Will let you know how it goes

Basel_Kirmani
Level 2

Re: Including tokens in a velocity script

Thank you Darshil!

I really really appreciate your taking the time to add the commented "set variable" logic at the beginning. That was extremely helpful in getting me to understand how it all works.

 

Regards,

Basel

Darshil_Shah1
Level 10 - Community Advisor

Re: Including tokens in a velocity script

Sure, I am glad that you were able to follow the script. 🙂

 

Be sure to check out Sandy's #displayIfFilled Velocimacro article, it would enable you to get away from writing #if-else constructs to print the default values for each field.

 

Best,
Darshil
Jo_Pitts1
Level 10 - Community Advisor

Re: Including tokens in a velocity script

@Basel_Kirmani ,

Interestingly, something a lot of people don't realise is that you don't HAVE to do all of that inside the token if you don't want.

You can have two velocity tokens something along these lines:

my.displayIfHasAgent

#if( ! ${lead.agent}.equals("W99999" ) )

and a much more generic one:

my.endIf

#end

You can then write a standard Marketo module with these tokens embedded in it.  This means you get to see the output in the editor, and (for me at least) makes things easier to manage.

If you want to stop the tags from showing in the editor for your Marketo users, you can do this

<!--
{{my.displayIfHasAgent}}
-->

 

Cheers

Jo

SanfordWhiteman
Level 10 - Community Moderator

Re: Including tokens in a velocity script

Note this technique is for advanced Velocity users, so it’s not recommended if you’re just getting started with the language. It inherently makes things easier to break as you’re not writing compilable VTL within a single token.

Jo_Pitts1
Level 10 - Community Advisor

Re: Including tokens in a velocity script

@SanfordWhiteman,

So firstly.. I 100% agree with you about the risks of this approach. 

Secondly.. when the heck did I become an advanced Velocity user?  That's a bewildering prospect!

Basel_Kirmani
Level 2

Re: Including tokens in a velocity script

Thank you Jo! Sorry, I haven't had a chance to try out your solution yet, but just wanted to post a thank you for taking the time so far. Will let you know how it goes. Also, in the meantime: Congratulations on your promotion to "Advanced Velocity User" 💪