SOLVED

Script showing something different in the preview than the test

Go to solution
Michael_McGowa1
Level 3

Script showing something different in the preview than the test

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

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

You can check for either value:

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

View solution in original post

17 REPLIES 17
SanfordWhiteman
Level 10 - Community Moderator

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

Rule #1 with Velocity is that you don't use Send Sample to test, you use a real email!
Michael_McGowa1
Level 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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