I am building in email where there is different messaging for recipients based on the amount of points they have in their account. This text is in a module and the module contains the following script;
{% set rfPointTotal = contact.rf_points_total %} {% if rfPointTotal == 0 %} <p style="mso-line-height-rule:exactly; font-family:Arial, sans-serif; font-size:15px; color:#333333; word-break:break-word;mso-line-height-rule:exactly; line-height:175%">Since there are no points in your profile, there is nothing more for you to do. <br>Thank you,<br>The RewardFish Team</p> {% elif rfPointTotal > 0 and rfPointTotal <= 499 %} <p style="mso-line-height-rule:exactly; font-family:Arial, sans-serif; font-size:15px; color:#333333; word-break:break-word;mso-line-height-rule:exactly; line-height:175%">As of this date you still have <strong>{{ rfPointTotal }} points</strong> left in your account.</p> {% else %} <p style="mso-line-height-rule:exactly; font-family:Arial, sans-serif; font-size:15px; color:#333333; word-break:break-word;mso-line-height-rule:exactly; line-height:175%">As of this date you still have <strong>{{ rfPointTotal }} points</strong> left in your account which means you can redeem your points for a gift card. Please log into your account and go to Claim Gift Card to start the process before it's too late.</p> {% endif %}
The field contact.rf_points_total is a formatted number field. The script works until I come across a member with 1,000 points or more. When I look at the preview of a member who has over 1,000 points I see the following
When I try to send a test email, it fails.
My conclusion is that it doesn't like the comma in the formatted number field. I did make a copy of this field unformatted, and made a workflow to copy the values from the formatted field to the unformatted field. The script works fine but I do not like this solution as it would be possible to send an email with the wrong value in the unformatted field. Furthermore, the formated field is updated every 10 minutes and is used in other places so I cannot just change the formatted field to an unformatted field.
Is there a way to get my script to work looking only at the formatted field and not breaking?
Hey, @mmcgowan702👋 Thanks for the interesting question. It sounds like we need some way to escape that comma when it is used in your module.
Looking at the available HubL filters, I found `replace`. Have you looked into this yet? I haven't tested this in a module, but this is a simple example:
{% set rfPointTotal = contact.rf_points_total|replace(",", "")|int %}
Hey, @mmcgowan702👋 Thanks for the interesting question. It sounds like we need some way to escape that comma when it is used in your module.
Looking at the available HubL filters, I found `replace`. Have you looked into this yet? I haven't tested this in a module, but this is a simple example:
{% set rfPointTotal = contact.rf_points_total|replace(",", "")|int %}