<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Check if contact property is empty in email templates in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018290#M40038</link>
    <description>&lt;P&gt;Hello, I am trying to figure out how to check if a contact property is empty via hubl we have so far&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% if contact.added_to_our_list_after is not defined or contact.added_to_our_list_after == '' or contact.added_to_our_list_after is none %}
&amp;lt;!-- Do something if the property is empty, not defined, or null --&amp;gt;
&amp;lt;p&amp;gt;The contact has not been added to our list after a specific date.&amp;lt;/p&amp;gt;
{% else %}
&amp;lt;!-- Do something if the property is not empty --&amp;gt;
&amp;lt;p&amp;gt;The contact was added to our list after: {{ contact.added_to_our_list_after }}&amp;lt;/p&amp;gt;
{% endif %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But it doesn't work, it always goes into the else statement, so something I am clearly missing with the value of&amp;nbsp;&lt;STRONG&gt;contact.added_to_our_list_after&lt;/STRONG&gt; when blank&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2024 18:27:49 GMT</pubDate>
    <dc:creator>MNick2</dc:creator>
    <dc:date>2024-07-29T18:27:49Z</dc:date>
    <item>
      <title>Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018290#M40038</link>
      <description>&lt;P&gt;Hello, I am trying to figure out how to check if a contact property is empty via hubl we have so far&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% if contact.added_to_our_list_after is not defined or contact.added_to_our_list_after == '' or contact.added_to_our_list_after is none %}
&amp;lt;!-- Do something if the property is empty, not defined, or null --&amp;gt;
&amp;lt;p&amp;gt;The contact has not been added to our list after a specific date.&amp;lt;/p&amp;gt;
{% else %}
&amp;lt;!-- Do something if the property is not empty --&amp;gt;
&amp;lt;p&amp;gt;The contact was added to our list after: {{ contact.added_to_our_list_after }}&amp;lt;/p&amp;gt;
{% endif %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But it doesn't work, it always goes into the else statement, so something I am clearly missing with the value of&amp;nbsp;&lt;STRONG&gt;contact.added_to_our_list_after&lt;/STRONG&gt; when blank&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 18:27:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018290#M40038</guid>
      <dc:creator>MNick2</dc:creator>
      <dc:date>2024-07-29T18:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018907#M40060</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264463"&gt;@MNick2&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; I have a few additional troubleshooting questions for you:&lt;/P&gt;
&lt;P&gt;— Have you tried adding a temporary debugging line in your template to output the value of contact.added_to_our_list_after to see what is actually being returned?&amp;nbsp;This may help you understand why the logic might be falling into the else statement.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;p&amp;gt;Debug: {{ contact.added_to_our_list_after }}&amp;lt;/p&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;—&amp;nbsp;Ensure that contact.added_to_our_list_after is being returned as a string. Sometimes date fields might behave differently, especially if they are being treated as Date objects. If so,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;comparing it against a default date might help:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if contact.added_to_our_list_after == '1970-01-01T00:00:00Z' or contact.added_to_our_list_after == '' or contact.added_to_our_list_after is none %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've already ruled these out, or they don't help, please let me know, and we can tag in a few of our community members who are experts with HubL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Talk soon! — Jaycee&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 18:02:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018907#M40060</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-07-30T18:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018911#M40061</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Yup, have done that.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Returns nothing, empty string is my assumption. Wish there was a TYPEOF or something.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But the property itself, is a empty string, where we can enter anything into it like "added after newsletter" etc, just a basic string.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But when it's empty, nothing there, no conditional ideas are working in email templates to check if it's empty.&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Jul 2024 18:09:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018911#M40061</guid>
      <dc:creator>MNick2</dc:creator>
      <dc:date>2024-07-30T18:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018912#M40062</link>
      <description>Yup, have done that.&lt;BR /&gt;&lt;BR /&gt;Returns nothing, empty string is my assumption. Wish there was a TYPEOF or&lt;BR /&gt;something.&lt;BR /&gt;&lt;BR /&gt;But the property itself, is a empty string, where we can enter anything&lt;BR /&gt;into it like "added after newsletter" etc, just a basic string.&lt;BR /&gt;&lt;BR /&gt;But when it's empty, nothing there, no conditional ideas are working in&lt;BR /&gt;email templates to check if it's empty.&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jul 2024 18:09:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018912#M40062</guid>
      <dc:creator>MNick2</dc:creator>
      <dc:date>2024-07-30T18:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018920#M40063</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/17186"&gt;@Anton&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/61659"&gt;@Stephanie-OG&lt;/a&gt;, do&amp;nbsp;you have any additional troubleshooting tips for&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264463"&gt;@MNick2&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you! — Jaycee&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 18:16:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1018920#M40063</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-07-30T18:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1019133#M40069</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264463"&gt;@MNick2&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;There is the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#type" target="_blank" rel="noopener"&gt;"type" function&lt;/A&gt; that will function similarly to typeof in JS.&lt;/P&gt;
&lt;P&gt;In your case its important to&amp;nbsp;remember that date fields are &lt;STRONG&gt;nullable&lt;/STRONG&gt; meaning these type of values are designed to hold a null value representing the&amp;nbsp;absence of a value. Thus an "empty" date property will be null to represent the no date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;{{type(contact.added_to_our_list_after) == "null"}} {# true #}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also force a string value and&amp;nbsp;check the length:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;{% set temp_val = contact.added_to_our_list_after|string %}
{% if temp_val|length &amp;lt;=0 %} {# true %}
…&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this gets you going!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 00:40:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1019133#M40069</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2024-07-31T00:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Check if contact property is empty in email templates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1019666#M40093</link>
      <description>&lt;P&gt;Thanks &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73772"&gt;@Kevin-C&lt;/a&gt;&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":raising_hands:"&gt;🙌&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 18:59:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Check-if-contact-property-is-empty-in-email-templates/m-p/1019666#M40093</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-07-31T18:59:49Z</dc:date>
    </item>
  </channel>
</rss>

