HubL using custom contact properties in if statements in an email template using Design Manager
SOLVE
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!