Using custom data from our app in email template if statements


#1

I spent yesterday afternoon attempting to get a module within an email template to work. We have an if statement here that we'd like to utilize based on a variable we're passing in from our app. No matter what I seem to do, the if statement seems to ignore the variable value and always render the else condition.

As you can see from the code below, I've setup a number of tests to attempt figure out whats going on. I wanted to make sure the variable we're getting from our app (custom.reason) was both available as well as the correct value, I wanted to make sure whatever value I'm comparing to reason is the same value as reason (exceeded) and I wanted to test that our if logic is setup correctly - test1. All of these tests seem to return what's expected, but when comparing reason vs exceeded ({% if reason == exceeded %}), nothing seems to render - even though the values are the exact same given the test I've run. Is it possible to use custom data from our app in this way? I saw a note in docs saying its not possible to use "personalization variables", but it seems silly to not be able to use our app data. Any help would be appreciated.

Code:
{% set reason = custom.reason %}
{% set exceeded = "exceeded_rewardable_review_count" %}

<p>Reason outside = {{reason}}</p>
<p>Exceeded outside = {{exceeded}}</p>

{% if reason == exceeded %}
	<p>Success!</p>
{% endif %}

{% set test1 = "this is a test string" %}  

{% if test1 == "this is a test string" %}
	<p>Reason inside = {{reason}}</p>
	<p>exceeded inside = {{exceeded}}</p>
  <p dir="ltr" style="line-height: 125%;"><span style="font-size:15px"><span style="font-family:roboto,helvetica neue,helvetica,arial,sans-serif">
    Unfortunately you've reached the maximum number of gift cards we give out for reviews. You can read more about our moderation process and reward guidelines 
    <a data-click-track-id="5400" href="https://www.g2crowd.com/static/community_guidelines"><u>here.</u></a></span></span></p>
{% elif reason == '' %}
	<p>Reason inside = {{reason}}</p>
	<p>exceeded inside = {{exceeded}}</p>
  <p dir="ltr" style="line-height: 125%;"><span style="font-size:15px"><span style="font-family:roboto,helvetica neue,helvetica,arial,sans-serif">
    Unfortunately, you just missed the cut-off to be eligible for a gift card. You can read more about our moderation process and reward guidelines 
    <a data-click-track-id="9100" href="https://www.g2crowd.com/static/community_guidelines"><u>here.</u></a></span></span></p>
{% endif %}

#2

No worries - I spoke with a support representative regarding this issue.

I'll put this here for anyone else searching for this information:

Turns out we cant use contact or company data within email template logic (which is referenced in the if statement docs in hubspot), but more importantly we cannot use data we pass in from our app in email template logic - this information is not currently referenced in the docs.

So what this means is we’ll need to code logic within our mailers/app, create multiple templates in hubspot and send the specific template email id we want rendered based on that logic within our app. This is a pain from a developer standpoint - requiring much more code on our end, but doable. The reason the logic doesnt work is because of the way hubspot compiles the code - the data we pass from our app isnt available at the time they evaluate any logic within the template… again this means we can render our app data, but currently cannot use our data for any type of logic within email templates.