HubL, Email Module & Contact Properties

I have a contact property: contact.reader_type_1

It has an enum list of string values.

I have a module.

When I output the contact’s reader type:

{{ contact.reader_type_1 }} I get “BOOKWORM” (no quotes)

But, if I do {{ contact.reader_type_1 == “BOOKWORM” }} I get false. I’ve tried single quotes, I’ve tried reader_type_1.value .name and .label

I’ve tried doing this in preview-as-contact in browser as well as sending a test email.

How can I do a comparison against a string value so that I can customize what a user sees in email based off their reader_type?

Also - At this point, it is not an option for me to change it to a string field, so many things are tied to it being a select/enum.

Hi @NRuffilo

There’s an example of how to do this in the If Statement Docs.

In there example they set the ENUM to a variable and use it for comparison. The only significant difference is they wrap the If Statement in {% %} rather than {{ }} which outputs a staring.

Here’s the example from the link above:

{% choice "department" label="Choose department", value="Marketing", choices="Marketing, Sales, Dev, Services" export_to_template_context=True %}

{% if widget_data.department.value == "Marketing" %}

<h3>Want to join our amazing Marketing team?!</h3>
<h4>We have exciting career opportunities on the {{ widget_data.department.value }} team.</h4>

{% elif widget_data.department.value == "Sales" %}

<h3>Are you a Sales superstar?</h3>
<h4>We have exciting career opportunities on the {{ widget_data.department.value }} team.</h4>

{% elif widget_data.department.value == "Dev" %}

<h3>Do you love to ship code?</h3>
<h4>We have exciting career opportunities on the {{ widget_data.department.value }} team.</h4>

{% else %}

<h3>Want to work with our awesome customers?</h3>
<h4>We have exciting career opportunities on the {{ widget_data.department.value }} team.</h4>

{% endif %}

Have fun

Mike

Here to learn more about HubSpot and share my HubSpot Knowledge. I’m the founder of Webalite a Gold HubSpot Partner Agency based in Wellington, New Zealand and the founder of Portal-iQ the world’s first automated HubSpot Portal Audit that helps you work smarter with HubSpot.

Thank you for the response, but sadly it does not work. Here is the code:
{% if contact.reader_type_1.value == “GAME DAY HERO” %}
Yay! I’m a game day hero<br/>
{% else %}
I am not :disappointed_face: <br/>
{% endif %}
rt1 print: {{ contact.reader_type_1 }}<br/>
rt1 value: {{ contact.reader_type_1.value }}<br/>

And here is the output:

I am not :disappointed_face:

rt1 print: GAME DAY HERO
rt1 value: GAME DAY HERO
So contact.reader_type_1.value and contact.reader_type_1 both print out to “GAME DAY HERO” but do not evaluate when comparing to the string value.
I am doing this through a test email.