HUBL code not working

Hey guys,

I wrote the below code which displays a sentence based on what the property on the contact is, if my testing its “ProTrading” which is also displayed in my debug code.

However in every test I perform, only the Else sentence is displayed which is weird, I tried to use “==” then used “Contains” and still doesn’t work (Output Screenshot attached).

Did anybody else face this issue before or is something wrong with the code? much appreciated

{% if {{ personalization_token(‘contact.account_type__backend_account_created_’, ’ ') }} contains “Interest” %}
<p>We are pleased to inform you that your request to open a new <b>Trading Account</b> has been processed.</p>
{% elif {{ personalization_token(‘contact.account_type__backend_account_created_’, ’ ') }} contains “ProTrading” %}
<p>We are pleased to inform you that your request to open a new <b>Pro Trading Account</b> has been processed.</p>
{% else %}
<p>DEBUG: account_type = “{{ personalization_token(‘contact.account_type__backend_account_created_’, ’ ') }}”</p>
<p>We are pleased to inform you that your request to open a new <b>Account</b> has been processed.</p>
{% endif %}

Hey @Rodolpheb,

thanks for providing the code.
When previewing the page, are you setting the preview to “View as Contact XYZ”? Also, if you open the page in a new tab, the set preview settings are not applied - you have to preview/debug in the “Preview window”. Important note: The contact you’re using for preview should have “Interest” oder “Pro Trading” set in the property you’re checking for.

From my experience writing if-statements with personalization tokens works best like this:

{% if contact.account_type__backend_account_created_ == "Interest" %}
...
{% elif contact.account_type__backend_account_created_ == "Pro Trading" %}
...
{% else %}
...
{% endif %}

A few things here:

  • “double curlys” don’t work inside a statement
  • Writing “elif” without a value will most likely return a boolean which is a behaviour you don’t want in this scenario as this is comparable to the “else”

Hope this helps

best,

Anton

Hi Anton,

Thanks for your reply.

The screenshot is taken directly from the received email that I triggered, and the property is set to “ProTrading” but it’s being regarded as Else.

I aslo tried code similar to yours, same issue, it gets referenced as Else instead of ProTrading. Very weird.

How are you previewing this, as @Anton mentioned. This is going to be very important.
If you are in an incognito window, it won’t know who you are. I’d try logging out information like this in your page/email/module/whatever this is in -- and that will show you what the current contact’s data is.

<h2>ACCOUNT TYPE BACKEND: {{ contact.account_type__backend_account_created_|pprint }}</h2>

Once you can see that, then you should know if the value is actually showing up or if you are reveiwing this incorrectly. Using a preview link ?hs_preview… from the website pages won’t bring this data in correctly.