APIs & Integrations

fcomstoc
Member

If statement contact property

Hello Everyone,

I am attempting to create an email that shows content based on contact properties, but for some reason the if statements don’t seem to work. If I put in the HUBL for the contact property it will show up, but the if statement will not.

Here is the code from the email template:


{{contact.do_you_have_small_children_or_pets_}}
{% if contact.do_you_have_small_children_or_pets_ == ‘Yes’ %}

Text for small children and pets.


{% endif %}


{{contact.are_the_windows_in_a_hard_to_reach_spot_}}
{% if contact.are_the_windows_in_a_hard_to_reach_spot_ == ‘Yes’ %}

Text for hard to reach windows.


{% endif %}

I know the contact properties are correct and are loading because I get the double ‘Yes’ in the email if I send it as if it is going to the user with the 2 Yes properties. I am thinking there is a problem with the if statement or I am not reading the contact property field properly. Sorry I usually work with PHP.

If anyone has any ideas I would greatly appreciate it.

0 Upvotes
3 Replies 3
BiG
Contributor

If statement contact property

Yes, this is currently not implemented.

We added the query to have HUBL if's for emails, too.

If you agree, please support this idea which queries for if statements in HUBL for emails:
https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907

Thank you very much!

0 Upvotes
zwolfson
HubSpot Employee
HubSpot Employee

If statement contact property

@fcomstoc this is actually expected behavior. The HubL logic executes before the the contact property personalization tokens are filled in so the if statement will always evaluate to false.

The best way to accomplish this is to use Smart Content. You could create a list for people who “have small children or pets” then have a rich text module in your template. That module can be made smart based on the list you created.

NOTE that a module that has been made smart acts more like switch statement in PHP so you can have multiple versions of the same module beyond the simple “yes it is true or no it’s not” style logic.

0 Upvotes
hojjohan
Participant | Diamond Partner
Participant | Diamond Partner

If statement contact property

Hallo

using hubl in an email is supported for the moment in HubSpot

Johan

0 Upvotes