SOLVED

Re: Script showing something different in the preview than the test

Go to solution
Michael_McGowa1
Level 3

I have a script in an email that is adding the dollar amount of offers a person is eligible for and showing that in the subject line and the body. 

When I look at the email in the preview it is working as it should. Here is a screenshot.

preview.png

However, when I send a test email, I am seeing the following.

outlook.png

What is happening?

Here is the script I am using.

##********Finding out if they came through the CoReg
#set ($coReg = ${lead.mktocoreg})
#set ($coReg2Scp = ${lead.mktocoreg2scp})
#if($coReg.equals("niche"))
#set ($coRegMkt = "yes")
#elseif ($coReg.equals("campusreel"))
#set ($coRegMkt = "yes")
#else
#set ($coRegMkt = "no")
#end
##********Finding out if they came through the CoReg and converted or Just Member
#if(($coReg2Scp.equals("")) && ($coRegMkt.equals("yes")))
#set ($scpMember = "Coreg Not a Member")
#elseif (($coReg2Scp.equals("1")) && ($coRegMkt.equals("yes")))
#set ($scpMember = "Coreg but member")
#else 
#set ($scpMember = "Member")
#end
##******************Eligible or Taken Bold**********
#set ($takenBold = ${lead.mktotakenBold})
#set ($eligibleBold = ${lead.mktoeligiblebold})
#if (($eligibleBold.equals("1")) && ($takenBold.equals("")))
#set ($showBold = 25000)
#else
#set ($showBold = 0)
#end
##******************Eligible or Taken Niche**********
#set ($takenNiche = ${lead.mktotakenNiche})
#set ($eligibleNiche = ${lead.mktoeligibleniche})
#if (($scpMember.equals("Coreg Not a Member")) && ($coReg.equals("niche")))
#set ($showNiche = 0)
#elseif (($eligibleNiche.equals("")) && ($coReg.equals("campusreel")) && ($takenNiche.equals("")))
#set ($showNiche = 2000)
#elseif (($eligibleNiche.equals("1")) && ($takenNiche.equals("")))
#set ($showNiche = 2000)
#else
#set ($showNiche = 0)
#end
##******************Eligible or Taken Christian Connector**********
#set ($takenCC = ${lead.mktotakenChristianConnector})
#set ($eligibleCC = ${lead.mktoeligiblechristianc})
#if (($eligibleCC.equals("1")) && ($takenCC.equals("")))
#set ($showCC = 2500)
#else
#set ($showCC = 0)
#end
##******************Eligible or Taken Nitro**********
#set ($takenNitro = ${lead.mktotakenNitro})
#set ($eligibleNitro = ${lead.mktoeligiblenitro})
#if (($eligibleNitro.equals("1")) && ($takenNitro.equals("")))
#set ($showNitro = 2000)
#else
#set ($showNitro = 0)
#end
##Adding up the dollars available
#set ($subtotal = $math.add($showNiche, $showBold, $showNitro, $showCC))
#set ($formattedTotal = $number.format("number", $subtotal))
$${formattedTotal}

 

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

You can check for either value:

$value.isEmpty() || $value.equals("0")

View solution in original post

17 REPLIES 17
SanfordWhiteman
Level 10 - Community Moderator
Rule #1 with Velocity is that you don't use Send Sample to test, you use a real email!
Michael_McGowa1
Level 3

I sent a real email and this problems persists. Can you tell me what is causing this and how to fix it?

SanfordWhiteman
Level 10 - Community Moderator

Please include the output of a VTL token with just

${lead}

as well as the output of this VTL token. (Include both tokens in the same email.)

Michael_McGowa1
Level 3

I updated the code as you suggested but still having the problem. Here is the new code:

##********Finding out if they came through the CoReg
#set ($coReg = ${lead.mktocoreg})
#set ($coReg2Scp = ${lead.mktocoreg2scp})
#if($coReg.equals("niche"))
#set ($coRegMkt = "yes")
#elseif ($coReg.equals("campusreel"))
#set ($coRegMkt = "yes")
#else
#set ($coRegMkt = "no")
#end
##********Finding out if they came through the CoReg and converted or Just Member
#if(($coReg2Scp.equals("")) && ($coRegMkt.equals("yes")))
#set ($scpMember = "Coreg Not a Member")
#elseif (($coReg2Scp.equals("1")) && ($coRegMkt.equals("yes")))
#set ($scpMember = "Coreg but member")
#else 
#set ($scpMember = "Member")
#end
##******************Eligible or Taken Bold**********
#set ($takenBold = ${lead.mktotakenBold})
#set ($eligibleBold = ${lead.mktoeligiblebold})
#if (($eligibleBold.equals("1")) && ($takenBold.equals("")))
#set ($showBold = 25000)
#else
#set ($showBold = 0)
#end
##******************Eligible or Taken Juno**********
##set ($takenJuno = ${lead.mktotakenJuno})
##set ($eligibleJuno = ${lead.mktoeligiblejuno})
##if (($eligibleJuno.equals("1")) && ($takenJuno.equals("")))
##set ($showJuno = 2500)
##else
##set ($showJuno = 0)
##end
##******************Eligible or Taken Niche**********
#set ($takenNiche = ${lead.mktotakenNiche})
#set ($eligibleNiche = ${lead.mktoeligibleniche})
#if (($scpMember.equals("Coreg Not a Member")) && ($coReg.equals("niche")))
#set ($showNiche = 0)
#elseif (($eligibleNiche.equals("")) && ($coReg.equals("campusreel")) && ($takenNiche.equals("")))
#set ($showNiche = 2000)
#elseif (($eligibleNiche.equals("1")) && ($takenNiche.equals("")))
#set ($showNiche = 2000)
#else
#set ($showNiche = 0)
#end
##******************Eligible or Taken Christian Connector**********
#set ($takenCC = ${lead.mktotakenChristianConnector})
#set ($eligibleCC = ${lead.mktoeligiblechristianc})
#if (($eligibleCC.equals("1")) && ($takenCC.equals("")))
#set ($showCC = 2500)
#else
#set ($showCC = 0)
#end
##******************Eligible or Taken Nitro**********
#set ($takenNitro = ${lead.mktotakenNitro})
#set ($eligibleNitro = ${lead.mktoeligiblenitro})
#if (($eligibleNitro.equals("1")) && ($takenNitro.equals("")))
#set ($showNitro = 2000)
#else
#set ($showNitro = 0)
#end
##Adding up the dollars available
#set ($subtotal = $math.add($showNiche, $showBold, $showNitro, $showCC))
#set ($formattedTotal = $number.format("number", $subtotal))
${formattedTotal}

In the body and subject line of the email, I have the token {{my.dollarAmt}}. The reason why I had two dollar signs in the output is because this is to show a dollar amount (i.e. $25,000). I'm at a loss of what to do and frustrated that when I look at the preview, the code is working as it should. It's when I send the email that it shows 0. What am I missing in the code so the correct number gets into the send email and is in a US currency format?

 

SanfordWhiteman
Level 10 - Community Moderator

There’s not enough information here — like I said, need to see the raw output of the $lead and the output of your {{my.token}}, in the same email.

Michael_McGowa1
Level 3

I am not sure what you mean. Do you need to see the code of the email where this appears? Here is that.

 You qualify for these easy scholarships worth: {{my.dollarAmt}} 

Here is the output that I am seeing:

outlook.png

Here is what I see in the preview:

preview.png

Let me know if you need anything else.

SanfordWhiteman
Level 10 - Community Moderator

Need to see the output of this Velocity token:

${lead}

 Create a {{my.token}} with only that code. Include the token after your other token, in the same email. Then post the full output. Preferably in the text part of the email as it’ll be most readable.

Michael_McGowa1
Level 3

Here is the output of the email after I sent it. This is being viewed in Outlook but also comes out this way in other ISPs like Gmail.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head> 
<body><div class="mc-ip-hide"><div style="color:#000000; font-size:12px; text-align:left; font-family:Helvetica, Arial, sans-serif;"><strong>CAUTION: External email. Please use caution when clicking links or opening attachments</strong><br></div><hr></div> 
<div id="body" class="mktoText" style="font-family: Helvetica, Arial, Sans-Serif; padding:10px;">

You qualify for these easy scholarships worth
0 this month:
</div>  

<!--Controlled by template-->
</body>
</html>

I also noticed that when I view the email as a webpage, the token renders as it should. Here is the output from the View as Webpage.

<div class="mktoText" id="text">
 

Hey Michael,

 
<br>
You qualify for these easy scholarships worth
29,000 this month: 
</div>

 

Hope this is what you are after. Let me know if you need anything else.

SanfordWhiteman
Level 10 - Community Moderator

Where is the output of the second token supposed to be?

Michael_McGowa1
Level 3

It's one token. Just the dollar amount is the token because it is used in the subject line as well as the body of the email.

SanfordWhiteman
Level 10 - Community Moderator

I’ve been asking that you create a 2nd token (see above) and add that {{my.token}} after your current one in the email. Not sure how that’s not coming across.

Michael_McGowa1
Level 3

Below is the new output with the new token with $lead in the script.

You needed me to make a new script token with just $lead in the script. That was the disconnect.

I hope this is what you are after.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head> 
<body><div class="mc-ip-hide"><div style="color:#000000; font-size:12px; text-align:left; font-family:Helvetica, Arial, sans-serif;"><strong>CAUTION: External email. Please use caution when clicking links or opening attachments</strong><br></div><hr></div> 
<div id="body" class="mktoText" style="font-family: Helvetica, Arial, Sans-Serif; padding:10px;">
$0
<span style="color: #000000; font-family: Helvetica, Arial, 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: start; 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;">{mktoEmailable=1, mktotakenNiche=0, mktotakenJuno=0, mktoeligibleniche=1, mktocoreg=, mktotakenBold=0, mktotakenChristianConnector=0, mktoeligiblebold=1, mktoeligiblechristianc=0, mktoeligiblejuno=0, mktoeligiblenitro=1, mktocoreg2scp=0, mktotakenNitro=0}</span>
</div>  

<!--Controlled by template-->
</body>
</html>

 

 

SanfordWhiteman
Level 10 - Community Moderator

Think I see the problem.

 

Please add this to the second token and post the output:

#foreach( $entry in $lead.entrySet() )
${entry.getValue().class} ${entry.getKey()} ${entry.getValue()} 
#end

 

Michael_McGowa1
Level 3

Added that code to the script. Here is the output from that.

<div class="mc-ip-hide"><div style="color:#000000; font-size:12px; text-align:left; font-family:Helvetica, Arial, sans-serif;"><strong>CAUTION: External email. Please use caution when clicking links or opening attachments</strong><br></div><hr></div> 
<div id="body" class="mktoText" style="font-family: Helvetica, Arial, Sans-Serif; padding:10px;">
$0
<span style="color: #000000; font-family: Helvetica, Arial, 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: start; 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;">{mktoEmailable=1, mktotakenNiche=0, mktotakenJuno=0, mktoeligibleniche=1, mktocoreg=, mktotakenBold=0, mktotakenChristianConnector=0, mktoeligiblebold=1, mktoeligiblechristianc=0, mktoeligiblejuno=0, mktoeligiblenitro=1, mktocoreg2scp=0, mktotakenNitro=0}
class java.lang.String mktoEmailable 1 
class java.lang.String mktotakenNiche 0 
class java.lang.String mktotakenJuno 0 
class java.lang.String mktoeligibleniche 1 
class java.lang.String mktocoreg  
class java.lang.String mktotakenBold 0 
class java.lang.String mktotakenChristianConnector 0 
class java.lang.String mktoeligiblebold 1 
class java.lang.String mktoeligiblechristianc 0 
class java.lang.String mktoeligiblejuno 0 
class java.lang.String mktoeligiblenitro 1 
class java.lang.String mktocoreg2scp 0 
class java.lang.String mktotakenNitro 0 
</span>
</div>
SanfordWhiteman
Level 10 - Community Moderator

Everywhere you’re comparing to the empty string "" you should be comparing to "0".

Michael_McGowa1
Level 3

I changed the code so I am comparing 0 instead of "" and seems to be working in the actual sends and test sends. The only issue is that if I look in the preview the token outputs $0 and if I view the email as a webpage it also shows $0. I can remove the view as webpage if needed but is there any way that it can be consistent? That the correct output be shown in the preview, sent email and viewed as a webpage? Otherwise, I'll call it resolved. Thank you for your help

SanfordWhiteman
Level 10 - Community Moderator

You can check for either value:

$value.isEmpty() || $value.equals("0")