Re: Velocity Script Code to pull in Custom Field

juleary324
Level 2

Hello, 

 

We are doing a "year-in-review" email for our customers, pulling in interesting stats relevant for their business. (example: you've sent [XX] messages this year." I've made custom fields for each data point we will pull in.  Here is an example of the API name for the field: Total_Repairs_YIR2026. 

 

I am struggling to create a velocity code to pull this field into the email. Our development team will eventually change the styling of the text to accommodate our design. 

 

Any suggestions to create a code that won't break the email?

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Why do think you need Velocity, rather than the fields’ corresponding {{lead.tokens}}? (There are many fitting reasons to use Velocity, just need more detail before continuing.)

juleary324
Level 2

If our developer is coding the email, can he still have the full capabilities of styling/catering to our design with the {{lead.tokens}}? We have some pretty large numbers being pulled into our modules, so making sure the formatting is correct is very important.

SanfordWhiteman
Level 10 - Community Moderator

The {{lead.token}} outputs the value verbatim, HTML-encoded.

 

Velocity would allow you to — among infinite examples — output an Integer in the Currency format for a particular locale, or round Integers.

 

Not sure what you mean by “pretty large numbers” and what you’re thinking of doing with Velocity.

Jo_Pitts1
Level 10 - Community Advisor

OK, so wherein lies the problem?  Just create a velocity token, format your numbers inside the token as required, and then output the numbers.  As long as you just output them as plain text, they'll get the formatting of the surrounding HTML.

 

What have you tried thus far?

 

Cheers

Jo