SOLVED

Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

Go to solution
Lucas_Metherall
Level 4

Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

hi all,

 

We are sending a summary email of donation amounts for the FY. We have custom currency field Total Amount of Gifts, and, because it is a currency field, it only takes numbers, not characters (i.e. $).

 

HOWEVER, trying to reference that token in the email, I write Total Gifts Received: ${{Total Amount of Gifts}}, and the token breaks in the live email. I just see a single }.

Anyone got any insight on this?

 

Thanks!

 

Broken code in Editor.PNGLive email broken.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token


I hoped you'd jump on this. Questions for you;
  • Why does ${{ break the token code?

Because the character sequence ${ is reserved: it's the start of a Velocity Template Language reference.

 

So the parser doesn't see an intact {{lead.token}} block, which is the Marketo token reference.

 

In the WYSIWYG do I simply type ${esc.d}{{lead.Gift Amount}} ? What command is {esc.d}?


${esc.d} is a Velocity escape sequence for a dollar sign. So we're adding a complete VTL sequence to be parsed (from ${ to closing }) and then the {{lead.token}} stands alone. In other words, the parsers don't trip over each other.


how bad is the currency data field? What are common problems with it? Is it Apple Maps bad?

Bad enough. It's a 16-bit float, so there aren't enough bits to represent common amounts without approximation — commonly called "rounding" but that's putting too rosy a face on it, FP rounding isn't like "nearest 100" because it's binary. And more approximation is enforced at the MySQL level. I wrote a blog about it a couple of years ago, you can search for it. Also lots of reading materials out there on floats.

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

Use

 

${esc.d}{{lead.token name}}

 

P.S. You should never, ever use Currency. It's a broken datatype and you'll lose data. 

Lucas_Metherall
Level 4

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

Hi Sanford,

 

I hoped you'd jump on this. Questions for you;

  • Why does ${{ break the token code?
  • In the WYSIWYG do I simply type ${esc.d}{{lead.Gift Amount}} ? What command is {esc.d}?
  • how bad is the currency data field? What are common problems with it? Is it Apple Maps bad?

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token


I hoped you'd jump on this. Questions for you;
  • Why does ${{ break the token code?

Because the character sequence ${ is reserved: it's the start of a Velocity Template Language reference.

 

So the parser doesn't see an intact {{lead.token}} block, which is the Marketo token reference.

 

In the WYSIWYG do I simply type ${esc.d}{{lead.Gift Amount}} ? What command is {esc.d}?


${esc.d} is a Velocity escape sequence for a dollar sign. So we're adding a complete VTL sequence to be parsed (from ${ to closing }) and then the {{lead.token}} stands alone. In other words, the parsers don't trip over each other.


how bad is the currency data field? What are common problems with it? Is it Apple Maps bad?

Bad enough. It's a 16-bit float, so there aren't enough bits to represent common amounts without approximation — commonly called "rounding" but that's putting too rosy a face on it, FP rounding isn't like "nearest 100" because it's binary. And more approximation is enforced at the MySQL level. I wrote a blog about it a couple of years ago, you can search for it. Also lots of reading materials out there on floats.

Lucas_Metherall
Level 4

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

Very helpful, thank you again.

Lucas_Metherall
Level 4

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token

Hi Sanford,

I followed the code instructions;

${esc.d}${{lead.wap_total amount of gifts:default=edit me}} 

The sentence in the email text editor reads: Amount Received: ${esc.d}${{lead.wap_total amount of gifts:default=edit me}}

 

The token is intended to pull in a dollar amount, but when sending a live test to myself, the email shows only a single } where I wanted the dollar amount to appear.

 

Am I doing something wrong?

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Dollar sign $ in front of token {{lead.DOLALR AMOUNT}} breaks the token


I followed the code instructions;

Not exactly. 🙂

 

I had said:

 

${esc.d}{{lead.wap_total amount of gifts:default=edit me}} 

 

 

But you're absolutely right, unfortunately there's been a regression and this no longer works in HTML parts (it does still work in Text parts). So switch to an alternate approach. I would also use a numeric default for clarity:

 

$#**#{{lead.wap_total amount of gifts:default=0}}