Re: Currency format in Dynamic content

Anonymous
Not applicable

Currency format in Dynamic content

We are wanting to format a currency field in a piece of dynamic content (i.e. show decimal places and comma separators e.g.$2,000.30) but have been told by Marketo that "Script tokens cannot be used in emails which have Dynamic Content".

Has anyone out there successfully used any simple velocity scripting to do this?

Tags (1)
7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Currency format in Dynamic content

It's incorrect to say that Velocity tokens do not work in emails that have dynamic content. They do not work *in the same sections* that are dynamic (this, too, is not completely true,  but I won't get into the exceptions here).

What else is happening in this dyn content section? Is it also segmented? How long is that section?

Anonymous
Not applicable

Re: Currency format in Dynamic content

The dynamic content is a segmented table on number of products so basically people with 1 product see a table with 1 row and 3 columns and people with 2 products see a table with 2 rows and 3 columns. 2 of the 3 columns contain currencies so we want to format these with comma separators and decimal points.

I set up a token as follows and this shows correctly in the email preview but breaks when we send an email sample or live send;

$number.currency($${lead.RolloverPrevYearTotal})

SanfordWhiteman
Level 10 - Community Moderator

Re: Currency format in Dynamic content

That doesn't exactly reveal the complexity of the table's HTML, but if it's simple enough just move the segmenting into the Velocity token itself.

#if( $lead.Segment_Number_of_Products == "1 Product")

<td>... stuff for people with 1 product...

#else

<td>... etc. ...

#end

Naturally, using VTL for segmented content ranges from the incredibly awesome to the I-wish-there-were-a-better-way, depending on your specific needs. But it is often the *only* way to accomplish your goal.

Anonymous
Not applicable

Re: Currency format in Dynamic content

Sorry, I'm not quite following your response.

We have set up a segmentation on products.

We have then set up a dynamic content module in our email so that a different table is displayed relevant to each segment.

We have set up a token, for example my.Currency, using this code to format a field in currency format;

$number.currency($${lead.RolloverPrevYearTotal})

In the email HTML, this is an example of the code we are using to insert this token into;

<td style="border-bottom: 1px solid #7ec142; padding: 10px 0; margin: 0;" align="center">

<div class="paragraph-table" style="font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #333;"><strong>{{my.Currency:default=edit me}}</strong><br /></div>

</td>

How would we need to set up a velocity token to format this field lead.RolloverPrevYearTotal in a currency format in a dynamic table?

SanfordWhiteman
Level 10 - Community Moderator

Re: Currency format in Dynamic content

The point is that Velocity is not just for tiny text snippets. Quite the opposite: VTL was designed from the start to output entire web pages. Hence you can output the entire table from a Velocity token.

When you use tokens + segments, you aren't using Dynamic Content™ in the sense of a segmented editable section or a segmented snippet.  But you're certainly creating dynamic content, in fact with more flexibility then you can get with the other options (for example, you can nest and interrelate segments).

So, simply put, you'd output the <table> from Velocity, checking the value of $lead.Segmentation_<segment name> to determine segment membership and managing rows/columns/formats accordingly.

Anonymous
Not applicable

Re: Currency format in Dynamic content

Appreciate your time and response Sanford.

I understand how this could be re-engineered entirely to use Velocity scripting instead of dynamic content but just to clarify, are you confirming that there is no easy way to format currencies using dynamic content?

SanfordWhiteman
Level 10 - Community Moderator

Re: Currency format in Dynamic content

I think it helps to treat Velocity as a first-class form of dynamic content. You might even find that it's easier to output HTML from Velocity, especially if there are multiple variations. I shudder at pasting different table HTML into elements and trying to maintain them. Def'ly would do this in VTL myself.

But dynamic elements or snippets can't execute Velocity because of order-of-operations, so no, those technologies will not work for you.