• Live group demo of Marketing Hub + Data Agent

    Standardize reporting, reduce manual work, and introduce AI without cleanup

    Join us on March 12
  • Ready to build your local HubSpot community?

    HUG leaders host events, spark connections, and create spaces where people learn and grow together.

    Become a HUG Leader

Formatting Currency Properties in HubL

GarySteinert
Member

I have a HTML block in an Email that I'm trying to add a value to.

This value comes from a currency property on a line item, and is passed in as a custom token.

 

I would like to display this as a simple number, rather than a currency amount but the formatting filters in HubL seem to be producing unexpected results.

 

For these inputs:

 

{{custom.unit_price|string|pprint}}
{{custom.unit_price|string|regex_replace("[^0-9.]", "")|pprint}}
{{"€12.25"|string|regex_replace("[^0-9.]", "")|pprint}}

 

I'm getting these outputs:

 

(String: €12.25)
(String: .)
(String: 12.25)

 

The first line confirms that the input is indeed a string with a number and a currency symbol.

 

The last line hard codes that value and performs the regex_replace successfully.

 

The middle line performs the same transformation to the input data and also removes the numbers.

 

Is there something weird about how HubSpot passes the currency field in to the email so it displays as a string but doesn't present as a string to the filter functions?

0 Upvotes
1 Accepted solution
GarySteinert
Solution
Member
Nothing at all, apart from maybe the fact that I'm passing it in as a custom token.

I've worked around the issue by adding a Format Data step into my workflow to convert that currency value into a plain number before passing it to the email but I'm still intrigued why this weird behaviour is happening.

View solution in original post

0 Upvotes
2 Replies 2
MichaelMa
Top Contributor

Hmm... that's very odd. I used your same filters and it showed the correct result for me:

 

MichaelMa_0-1757425466761.png

 

MichaelMa_1-1757425477299.png

 

Is there anything in your code that might be modifying the custom.unit_price before you output it?

 

0 Upvotes
GarySteinert
Solution
Member
Nothing at all, apart from maybe the fact that I'm passing it in as a custom token.

I've worked around the issue by adding a Format Data step into my workflow to convert that currency value into a plain number before passing it to the email but I'm still intrigued why this weird behaviour is happening.
0 Upvotes