# HubL String Comparison

**URL:** <https://community.hubspot.com/t/hubl-string-comparison/51082>\
**Category:** CMS Development\
**Created:** [February 8, 2022, 1:02pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082 "2022-02-08T13:02:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RhodriJ](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RhodriJ](https://community.hubspot.com/u/RhodriJ)\
**Post date:** [February 8, 2022, 1:02pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/1 "2022-02-08T13:02:34Z")

</div>

Hi, I’m having trouble using HubL with a basic string comparison which I’m hoping someone can spot where I’m going wrong.

```lia-code-sample
// {{ contact.hubspot_owner_id.email }} renders email@example.com
{% if contact.hubspot_owner_id.email == "email@example.com" %}

True

{% endif %}

```

When I render the email property into the email it does appear to be the same, though HubL doesn’t think that is the case and evaluates as false. It does appear to evaluate as true when I compare 2 hard coded strings but having no luck when using an object property. Could it be that the email property is not a string? I have tried the ‘string’ and ‘trim’ filters but that doesn’t seem to change anything.

What’s also strange is that in the email template editor it seems to evaluate as true and renders the block of HTML, but when sending an email preview to my inbox it doesn’t seem to be the case even though the email property is exactly the same.

Any help is greatly appreciated,

Thank you

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 9, 2022, 5:02pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/2 "2022-02-09T17:02:18Z")

</div>

@piersg , what are your thoughts?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 11, 2022, 9:43am UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/3 "2022-02-11T09:43:34Z")

</div>

Hi @RhodriJ ,

Try the following steps:

1. Check which type of values return by **contact.hubspot\_owner\_id.email**
2. If this returns array then please try following code:

{% set **dummyEmail** = “**[email@example.com](mailto:email@example.com)**” %}

{% if **contact.hubspot\_owner\_id.email[0]** == **dummyEmail** %}

True

{% endif %}

1. If it return single value then please try following code:

{% set **dummyEmail** = “[email@example.com](mailto:email@example.com)” %}

{% if **contact.hubspot\_owner\_id.email == dummyEmail** %}

True

{% endif %}  
Hope this helps!  
If we were able to answer your query, kindly help the community by marking it as a solution.  
Thanks and Regards.

---

<div class="post-metadata">

**Author:** ![RhodriJ](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RhodriJ](https://community.hubspot.com/u/RhodriJ)\
**Post date:** [February 11, 2022, 10:59am UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/4 "2022-02-11T10:59:56Z")

</div>

Hi [@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510),

Thank you for your input and help.

The type function does seem to be returning “str” rather than an array. When I set the dummy email, it renders true in the email template but when it’s sent to an inbox as a preview this isn’t the case even though the contact owner email value is exactly the same.

Any further suggestions would be greatly appreciated, as I’ve started to run out of ideas here.

Thanks!

---

<div class="post-metadata">

**Author:** ![DNguyen508](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@DNguyen508](https://community.hubspot.com/u/DNguyen508)\
**Post date:** [August 25, 2023, 10:19am UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/5 "2023-08-25T10:19:20Z")

</div>

@RhodriJ- Do you have a solution for this? I’m having the same problem with you.  
Thanks,

---

<div class="post-metadata">

**Author:** ![a\_funs](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@a\_funs](https://community.hubspot.com/u/a_funs)\
**Post date:** [September 5, 2023, 11:41pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/6 "2023-09-05T23:41:24Z")

</div>

I can’t believe this does not work, there is no way to do this in a template. On any other email marketing platform, this is the most simple functionality. Likely they implemented it DAY 1!

---

<div class="post-metadata">

**Author:** ![a\_funs](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@a\_funs](https://community.hubspot.com/u/a_funs)\
**Post date:** [September 6, 2023, 2:13pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/7 "2023-09-06T14:13:42Z")

</div>

I can confirm I have the same issue..

---

<div class="post-metadata">

**Author:** ![DATADEER](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@DATADEER](https://community.hubspot.com/u/DATADEER)\
**Post date:** [October 6, 2023, 12:30pm UTC](https://community.hubspot.com/t/hubl-string-comparison/51082/8 "2023-10-06T12:30:48Z")

</div>

Try activating the **“Programmable email module”** Beta in the respective Module.  
For me it worked after turning it on. Not sure if it was truly related or whether some cache just refreshed after turning this on. I could then use conditions like.

```lia-code-sample
{% if deal.quality_level == "GOOD" %}
<h1>good stuff</h1>
{% endif %}

```

 ![programmable email.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/5/85dda498aae07eeac3f719470f6c351baaa3bffd.jpeg)

``
