Hola! ¡Tenemos nuestra Comunidad en Español!

Hubspot calculated property

Highlighted
New Contributor

Hi,

 

I have created an personalised email in which we need to perform some calculation. The veriables are holding the data in string and trying to convert it into integer but for some reason the variable is giving me value 0 after conversion.

 

I am using "|int" filter for data conversion. Do ineed to use some other method not sure would need help with the same.

Reply
0 Upvotes
1 Reply
HubSpot Moderator

Hi @sachinFlock,

 

I've been playing around with this. When I run this code:

 

{% set numericString = "1" %}
<p>numericString: {{ numericString }}</p>
<p>type(numericString): {{ type(numericString) }}</p>

{% set numericStringToNum = numericString|int %}
<p>numericStringToNum: {{ numericStringToNum }}</p>
<p>type(numericStringToNum): {{ type(numericStringToNum) }}</p>

 

My second variable does come back as an integer type, with a value of 1. For what it's worth, I'm running my code in an email custom module. Could you tell me more about where specifically you're running your code? Or feel free to link me to your module so I can take a look.

 

Thanks.

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes