CMS Development

Thompson_DHARMA
Contributor

if then statement in email for deal property

SOLVE

I am using the edit HTML module in an email (not an email template) and trying to get the following bit of code to work:

{% if deal.deal_currency_code == 'USD' %}<p>usd text</p>{% else %}<p>non-usd text</p>{% endif %}

 

I am previewing it with the currency code property above it so that I can compare, but it only shows the else text.

The issue is not letter case. What am I missing here?

0 Upvotes
1 Accepted solution
Thompson_DHARMA
Solution
Contributor

if then statement in email for deal property

SOLVE

I have solved this myself. I created a Module in Design Manager and entered this code. 

{% set currency_code = deal.deal_currency_code | string %}
{% if currency_code == "USD" %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}

View solution in original post

0 Upvotes
4 Replies 4
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

if then statement in email for deal property

SOLVE

Hey @Thompson_DHARMA 

 

Check the type of the value using the type function:

{{ type(deal.deal_currency_codedeal.deal_currency_code) }}

 

If it's not "str" try converting it using the string filter first.

 

best

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Thompson_DHARMA
Contributor

if then statement in email for deal property

SOLVE

Thanks Kevin! With your advice I did use the string filter but it's still not working, unfortunately. 

We're tried all sorts:

 

{% if personalization_token('deal.deal_currency_code') == 'USD' %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}

 

{% set currency_code = personalization_token('deal.deal_currency_code') | string %}
{% if currency_code == 'USD' %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}

 

{% set currency_code = deal.deal_currency_code |  string %}
{% if currency_code == "USD" %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}

 



0 Upvotes
Thompson_DHARMA
Solution
Contributor

if then statement in email for deal property

SOLVE

I have solved this myself. I created a Module in Design Manager and entered this code. 

{% set currency_code = deal.deal_currency_code | string %}
{% if currency_code == "USD" %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}
0 Upvotes
Thompson_DHARMA
Contributor

if then statement in email for deal property

SOLVE

I also ran a print test using this and it came back false, even though the test deal is definitely USD.

{% if deal.deal_currency_code == "USD" %}<p>usd text</p>{% else %}
<p>non-usd text {{ deal.deal_currency_code == "USD" }}</p>{% endif %}

 

0 Upvotes