- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
HubL using custom contact properties in if statements in an email template using Design Manager
SOLVEJan 29, 2020 8:52 AM
Hello,
I want to use an email template for an email which will be used in a workflow. I created the template using Design Manager.
In contacts I defined prop1 and prop2 properties which are "Single-line text" type. prop1 and prop2 are updated using API calls from our platform and in case these are invalid or not yet set in our platform, I update them with 'N/A' value.
In email template I want to show a specific text for prop1 only if prop1 is not 'N/A' and another text if prop2 is not 'N/A'. To achieve this I added following code in email template:
PROP1: [{{ contact.prop1 }}] {% if contact.prop1 != 'N/A' %} Property 1 is valid: [{{ contact.prop1 }}] {% endif %} PROP2: [{{ contact.prop2 }}] {% if contact.prop2 != 'N/A' %} Property 2 is valid: [{{ contact.prop2 }}] {% endif %}
When I edit the email which uses above email template and go to "Preview", choose a contact which has prop1 set to 'N/A' (without quotes) and prop2 set to 'Something here', the result in the preview is:
PROP1: [N/A] Property 1 is valid: [N/A] PROP2: [Something here] Property 2 is valid: [Something here]
I searched other issues related to my problem, I tried using contact.prop1.value, contact.prop1|string != 'N/A'|string to be sure is not something related to prop1 type. Nothing works...
Any help is much appreciated.
Best regards,
Andy
Ps. I posted this issue on Email Marketing Tool forum, which might not be appropiate. An admin please delete that post. Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Jan 30, 2020 4:16 AM
Hi Kevin,
Thank you for your reply!
I received an answer in the other thread opened here: https://community.hubspot.com/t5/Email-Marketing-Tool/HubL-using-custom-contact-properties-in-if-sta... (again sorry for the duplicate, if an admin can merge these two threads would be perfect).
I understand string comparison is case sensitive and that's what I expected too.
I tried your code like this:
{% set n_a = 'N/A' %} {% set prop1 = contact.prop1 %} {# prop1 is 'N/A' #} {% set prop2 = contact.prop2 %} {# prop2 is 'Something here' #} Prop1: [{{ prop1 }}] {% if prop1|upper != n_a %} <li>Prop1: [{{ prop1 }}]</li> {% endif %} Prop2: [{{ prop2 }}] {% if prop2|upper != n_a %} <li>Prop2: {{ prop2 }}</li> {% endif %}
and the result:
Prop1: [N/A] Prop1: [N/A] Prop2: [Something here] Prop2: [Something here]
so basically if statements are not supported yet in email templates, but only in CMS and Blog pages.
Anyone having this issues please upvote these ideas (as @MatthewShepherd mentioned in the other thread):
https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content