Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Conditional statements and comparisons

Posted on by

I am trying to create a conditional statement for the marketing email. The statement should show text based on TWO FIELDS on the contact. I keep getting the same syntax error and I am lost here.

The fields on the contact are

  1. gendercode: Male (value: 1) and Female (value:2)
  2. new_Communicationsalutation: Formal and Informal

Communication Salutation is a custom field - option set that has the values: 

  • formal (value: 100.000.000)
  • informal (value: 100.000.001)

The statement is the following:

  • If contact is Male
  • If contact has a formal communication salutation

show:

Sehr geehrter Herr {{contact.lastname}}

else:

  • If contact is Male
  • If contact has INFORMAL communication salutation

show:

Lieber {{contact.firstname}}

The same will be applied to the Female.

The statement:

{{#if (eq contact.gendercode 1)}}{{#if (eq contact.new_Communicationsalutation 100.000.000)}}Sehr geehrter Herr {{contact.lastname}}{{/if}}{{/if}}

{{#if (eq contact.gendercode 1)}} {{#if (ne contact.new_Communicationsalutation 100.000.000)}}Lieber {{contact.firstname}}{{/if}}{{/if}}

{{#if (eq contact.gendercode 2)}} {{#if (eq contact.new_Communicationsalutation 100.000.000)}}Sehr geehrte Frau {{contact.lastname}}{{/if}}{{/if}}

{{#if (eq contact.gendercode 2)}} {{#if (eq contact.new_Communicationsalutation 100.000.000)}}Liebe {{contact.firstname}}{{/if}}{{/if}}

Error:  Dynamic content contains a syntax error (such as a missing curly bracket) in or near the following code: {{#if (eq contact.new_Communicationsalutation 100.000.000)}}Sehr geehrter Herr {{contact.lastname}}{{/i.

https://docs.microsoft.com/en-us/dynamics365/marketing/dynamic-email-content#conditional-statements-and-comparisons - this is what I used to create the statements: 

  • {{#if A}}{{#if B}}<DisplayedContent>{{/if}}{{/if}}

What am I doing wrong?

  • Suggested answer
    kevin_scx Profile Picture
    kevin_scx 45 on at
    RE: Conditional statements and comparisons

    There could be a few reasons as of why this happens:

    • The option set value is not valid
    • The capital at the beginning of the schema name is not valid
    • You are using an invalid relationship or one that has not been added to the marketing service yet

    I usually solve these issues by starting out very small and see when the error occurs.

    For example, try (in a new email):

    {{contact.new_Communicationsalutation}}

    Does this give any errors? If not, proceed with the following statement and only after that try to add the if-statements.

    Hope this helps!

  • kovinina Profile Picture
    kovinina on at
    RE: Conditional statements and comparisons

    I did try it and this is the error:

    2021_2D00_08_2D00_01-15_5F00_58_5F00_40_2D00_Marketing-Email_5F00_-Designer_5F00_-Email-3ka-_2800_Blank_2900_-_2D00_-Dynamics-365.png

  • kevin_scx Profile Picture
    kevin_scx 45 on at
    RE: Conditional statements and comparisons

    Have you tried removing the dots in your option set value? Although the system shows option set values with dots, they are stored without them in the database. 

    {{#if (eq contact.new_Communicationsalutation 100000000)}}

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans