SOLVED

Need help changing value from 100.0 to 100.00 using Velocity Script

Go to solution
Anonymous
Not applicable

Need help changing value from 100.0 to 100.00 using Velocity Script

Hello Community!

I am tasked with finding out how to add an additional decimal to a value for a numerical token as well as a comma to indicate "thousands". For example, we have a token called {{lead.DBC Balance}} that pulls in how many "savings credits" a person has in their account. Most of our members show as having between "0" and "1000's" of credits; however, some show numbers such as 850.0 or 12500, etc., with only one decimal place after the period and none of them displaying a comma to indicate "thousands" of credits.

My question is whether I can use Velocity Script to 1. Add a 1/100's decimal place, e.g., instead of just showing 850.0 we would like to show 850.00  & 2. Be able to add a comma indicating thousands, e.g., instead of showing 12500, be able to show, 12,500 or 2,000, etc.

Thank you for your help in advance!

Laura Kimball

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

This is my first time using Velocity Script....Which VS editor do you recommend I use?

There's only one. (Within Marketo, I mean.)

When you add an Email Script token (a.k.a. Velocity token) this is your editor. Note the tree on the right-hand side, where you check off fields that you want use in the Velocity context.

pastedImage_5.png

Then you include the name of the Velocity token in your email, i.e. {{my.velocityToken}}.

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

${number.format(",${esc.h}${esc.h}0.00",$lead.DBCBalance)}

Make sure to check off your DBC Balance field in the right-hand tree of Script Editor.  Also, I'm assuming the API/VTL name (which can't have spaces, so Marketo always converts it) is $lead.DBCBalance but you can drag the field into the Script Ed "canvas" to be sure.

Anonymous
Not applicable

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

Thank you Sanford!

This is my first time using Velocity Script....Which VS editor do you recommend I use?

Laura

SanfordWhiteman
Level 10 - Community Moderator

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

This is my first time using Velocity Script....Which VS editor do you recommend I use?

There's only one. (Within Marketo, I mean.)

When you add an Email Script token (a.k.a. Velocity token) this is your editor. Note the tree on the right-hand side, where you check off fields that you want use in the Velocity context.

pastedImage_5.png

Then you include the name of the Velocity token in your email, i.e. {{my.velocityToken}}.

Anonymous
Not applicable

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

Okay, got it...I kind of figured that out once I opened the token editor .

If I want to change the date format for an expiration date token (see below) from appearing in an email as 2018-04-12 to April 12, 2018, how would I set up the Velocity Script?

{{lead.Expiration Date:default=edit me}}

Thank you!

Laura Kimball

SanfordWhiteman
Level 10 - Community Moderator

Re: Need help changing value from 100.0 to 100.00 using Velocity Script

Can you open a new thread for this new question and mark my answer above as Correct? Thanks.