SOLVED

Trying to get $ figure through velocity scripting... help?

Go to solution
messier
Level 2

Re: Trying to get $ figure through velocity scripting... help?

It is a preview with a real email address populated that has the correct data in it.

messier
Level 2

Re: Trying to get $ figure through velocity scripting... help?

@SanfordWhiteman I do have another question now. I'm trying to use this script 3 times in my email with different data fields, but I can only get the original one to work. Do I have to do something different for each individual token? Or what am I doing wrong? I really appreciate the help as I learn velocity scripting.

Original

${number.format("${esc.d}${esc.h},${esc.h}${esc.h}${esc.h}", $lead.APPBURSELAMNT)}

#2

${number.format("${esc.d}${esc.h},${esc.h}${esc.h}${esc.h}", $lead.APPBURSELPMT)}

#3

${number.format("${esc.d}${esc.h},${esc.h}${esc.h}${esc.h}", $lead.APPTWN)}

After I set up the tokens and attempted to preview my data in the email, I received this preview error.

Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>Encountered ")" near</p> <div><pre ></pre></div>

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Trying to get $ figure through velocity scripting... help?

I didn't see any errors in my SB with three different email script tokens added in the email, each referencing the data from three different fields. Do you have any other email script added in the email apart from these three lines? Apologies if I'm missing out on anything here. Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: Trying to get $ figure through velocity scripting... help?

Agreed, the error is somewhere else.

Be aware that if you’re trying to use a literal dollar sign, even outside of a formal Velocity {{my.token}}, you should use the Velocity escape ${esc.d}.

messier
Level 2

Re: Trying to get $ figure through velocity scripting... help?

Let's try again. Here is the full error when I attempt to approve my email. 

 

Not Allowed

Validation Error approving CTA all campaigns_2022_06.ectaD2 —  <div>An error occurred when procesing the email Body! </div> <p>Encountered ")" near</p> <div><pre >Based on your application, it looks like you currently pay </pre><pre >&lt;b&gt;${number.format(&quot;${esc.d}${esc.h},${esc.h}${esc.h}${esc.h}&quot;,${lead.navientAPPBURSELPMT)}&lt;/b&gt;&amp;nbsp;each month on a total balance of&amp;nbsp;</pre><pre class="x-form-item-label">&lt;strong&gt;${number.format(&quot;${esc.d}${esc.h},${esc.h}${esc.h}${esc.h}&quot;, $lead.navientAPPBURSELAMNT)}&lt;/strong&gt;. Here are the different ways you can save:</pre><pre >&lt;/div&gt;&lt;/td&gt; </pre><pre >&lt;/tr&gt; </pre></div>
SanfordWhiteman
Level 10 - Community Moderator

Re: Trying to get $ figure through velocity scripting... help?

You’ve reversed the closing curly brace and closing comma.

messier
Level 2

Re: Trying to get $ figure through velocity scripting... help?

No, I have nothing else.