<?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 if statement on custom properties in Email in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206364#M8219</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to send a transactional email with Hubspot.&lt;/P&gt;&lt;P&gt;This email is HTML+Hubl and for some reason&amp;nbsp;my If statement is not working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we are sending a custom.properties sometimes with content to render and sometimes not.&lt;/P&gt;&lt;P&gt;so first I thought: Let's try to check if this property "is defined",&lt;/P&gt;&lt;P&gt;unfortunately, the API make mandatory to receive this custom property so "is defined" does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I thought let's always send something but when I have no content, set this property to "null" or false or a string.&lt;/P&gt;&lt;P&gt;Then I tried to test if my property is one of those and it is not working...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am lost, does someone has any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Sep 2018 09:20:00 GMT</pubDate>
    <dc:creator>blowltd</dc:creator>
    <dc:date>2018-09-12T09:20:00Z</dc:date>
    <item>
      <title>if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206364#M8219</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to send a transactional email with Hubspot.&lt;/P&gt;&lt;P&gt;This email is HTML+Hubl and for some reason&amp;nbsp;my If statement is not working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we are sending a custom.properties sometimes with content to render and sometimes not.&lt;/P&gt;&lt;P&gt;so first I thought: Let's try to check if this property "is defined",&lt;/P&gt;&lt;P&gt;unfortunately, the API make mandatory to receive this custom property so "is defined" does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I thought let's always send something but when I have no content, set this property to "null" or false or a string.&lt;/P&gt;&lt;P&gt;Then I tried to test if my property is one of those and it is not working...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am lost, does someone has any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 09:20:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206364#M8219</guid>
      <dc:creator>blowltd</dc:creator>
      <dc:date>2018-09-12T09:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206366#M8221</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/70523"&gt;@blowltd&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I've used HubL properties several times in my emails.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Everytime there is a property and I need to do conditional, I just use,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;{% if variable_name %}show your content{% endif %}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I use it the above way when I am using Custom Modules for my Email.&lt;BR /&gt;&lt;BR /&gt;If I want to use normal HubL variables,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;For Rich Text,

{% rich_text "my_module" label='My rich text module', html='Default module text' %}
{% if "my_module" %}
A module named "my_module" is defined in this template.
{% endif %}

For text fields,

{% text "product_names" label='Enter the product names that you would like to render the coupon ad for', value='all of our products', export_to_template_context=True %}

{% if widget_data.product_names.value %}
&amp;lt;div class="coupon-ad"&amp;gt;
&amp;lt;h3&amp;gt;For a limited time, get 50% off {{ widget_data.product_names.value}}! &amp;lt;/h3&amp;gt;
&amp;lt;/div&amp;gt;
{% endif %}

For choice fields,

{% choice "department" label='Choose department', value='Marketing', choices='Marketing, Sales, Dev, Services' export_to_template_context=True %}
        
{% if widget_data.department.value == 'Marketing' %}

&amp;lt;h3&amp;gt;Want to join our amazing Marketing team?!&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;We have exciting career opportunities on the {{ widget_data.department.value }} team.&amp;lt;/h4&amp;gt;

{% elif widget_data.department.value == 'Sales' %}

&amp;lt;h3&amp;gt;Are you a Sales superstar?&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;We have exciting career opportunities on the {{ widget_data.department.value }} team.&amp;lt;/h4&amp;gt;        
        
{% elif widget_data.department.value == 'Dev' %}
        
&amp;lt;h3&amp;gt;Do you love to ship code?&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;We have exciting career opportunities on the {{ widget_data.department.value }} team.&amp;lt;/h4&amp;gt;
        
{% else %}
        
&amp;lt;h3&amp;gt;Want to work with our awesome customers?&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;We have exciting career opportunities on the {{ widget_data.department.value }} team.&amp;lt;/h4&amp;gt;
        
{% endif %}   

For Checkbox / Boolean,

{% boolean "check_box" label='Show alert', value=True, export_to_template_context=True %}

{% if widget_data.check_box.value is truthy %}
&amp;lt;div class='alert'&amp;gt;Danger!&amp;lt;/div&amp;gt;
{% endif %}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Let me know if it helps...&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 09:27:55 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206366#M8221</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-12T09:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206367#M8222</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did try the first one:&lt;/P&gt;&lt;PRE&gt;{% if custom.my_variable %}
&amp;lt;p&amp;gt; Hello &amp;lt;/p&amp;gt;
{% endif %}&lt;/PRE&gt;&lt;P&gt;but when I send without this "custom.my_variable" to the API&lt;/P&gt;&lt;P&gt;The error I got from the API is:&lt;/P&gt;&lt;PRE&gt;Mismatch in custom properties between template and request.\n - Custom properties in the template, but not in the request:&lt;/PRE&gt;&lt;P&gt;So clearly I can't do this test as API refuses not to send the property.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 09:31:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206367#M8222</guid>
      <dc:creator>blowltd</dc:creator>
      <dc:date>2018-09-12T09:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206372#M8225</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/70523"&gt;@blowltd&lt;/a&gt;&amp;nbsp;Can you share your HubL Code declaring the variable?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 09:41:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206372#M8225</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-12T09:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206374#M8227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the declaration:&lt;/P&gt;&lt;PRE&gt;{% if custom.get_ready_3 %}
                                &amp;lt;table align="left" border="0" cellpadding="0" cellspacing="0" style="max-width:300px;" width="100%" class="mcnTextContentContainer"&amp;gt;
                                  &amp;lt;tbody&amp;gt;
                                    &amp;lt;tr&amp;gt;
                                      &amp;lt;td valign="top" class="mcnTextContent" style="padding-top:0; padding-left:18px; padding-bottom:9px; padding-right:18px;"&amp;gt;
                                        &amp;lt;div style="text-align: center;"&amp;gt;&amp;lt;img data-file-id="38533" height="50" src="https://img.blowltd.com/transactional/4.png" style="border: 0px initial ; width: 50px; height: 50px; margin: 0px;" width="50"&amp;gt;&amp;lt;br&amp;gt;
                                          &amp;lt;br&amp;gt;
                                          &amp;lt;span style="font-size:15px"&amp;gt;&amp;lt;span style="font-family:roboto,helvetica neue,helvetica,arial,sans-serif"&amp;gt;{{ custom.get_ready_3 }}&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;
                                        &amp;lt;/div&amp;gt;
                                      &amp;lt;/td&amp;gt;
                                    &amp;lt;/tr&amp;gt;
                                  &amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;
                                {% endif %} &lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Sep 2018 09:43:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/206374#M8227</guid>
      <dc:creator>blowltd</dc:creator>
      <dc:date>2018-09-12T09:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/261314#M11637</link>
      <description>&lt;P&gt;I have the same issue, did you ever resolve this? The accepted answer does not seem relevant to the issues we are facing with transactional emails using the single send API.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 23:21:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/261314#M11637</guid>
      <dc:creator>kincorvia</dc:creator>
      <dc:date>2019-03-25T23:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: if statement on custom properties in Email</title>
      <link>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/282932#M13083</link>
      <description>&lt;P&gt;I agree.&lt;/P&gt;&lt;P&gt;This is not a real solution to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the same issue.&lt;BR /&gt;See also:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hubspot.com/t5/CMS-Development/if-statements-in-email-templates/m-p/282907" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/CMS-Development/if-statements-in-email-templates/m-p/282907&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please support this idea which queries for if statements in HUBL for emails:&lt;BR /&gt;&lt;A href="https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 07:50:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/if-statement-on-custom-properties-in-Email/m-p/282932#M13083</guid>
      <dc:creator>BiG</dc:creator>
      <dc:date>2019-08-26T07:50:49Z</dc:date>
    </item>
  </channel>
</rss>

