CMS Development

sachinFlock
Membre

Hubspot calculated property

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.

3 Réponses
emilushi
Participant | Partenaire solutions Elite
Participant | Partenaire solutions Elite

Hubspot calculated property

@sachinFlock,

 

This is an issue daten from 2017 or eraly and still haven't been fixed.

 

Did you found any workaround?

lscanlan
Ancien salarié HubSpot
Ancien salarié HubSpot

Hubspot calculated property

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
0 Votes
sachinFlock
Membre

Hubspot calculated property

Hi @lscanlan,

Thanks for replying.

I'm working with a personalization token in the Email Manager. The converted type is integer but it returns 0.

Here's my code...

{% set percent_gb = personalization_token('contact.custom_file_storage_in_percentage', '0') %} 
{% set percent_gb_int = percent_gb|int %}
<p>{{ type(percent_gb) }}: {{ percent_gb }}</p> <!-- str: 47 -->
<p>{{ type(percent_gb_int) }}: {{ percent_gb_int }}</p> <!-- int: 0 -->

 

Thanks,
Sachin Vishwakarma
Flock.