Skip to main content

Notifications

Announcements

No record found.

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

Dynamics Content in E-Mail - Dynamic salutation programming based on a code list

Posted on by 140

Hi all,

i want to add a Dynamic salutation in an email template. We use an own field contact.a_salutation with a drop down value list for it.

There are three options: male (code 1), female (code 2) and gender neutral (not 1 or not 2)

How do I have to design the if query so that the third variant is drawn? Unfortunately it does not work at the moment.

My code looks like this:

#if (eq contact.a_salutation 1) Sehr geehrter
else if (eq contact.a_salutation 2) Sehr geehrte
/if
#if(ne contact.a_salutation 1){{#if(ne contact.a_salutation 2)}}Sehr geehrte(r)
/if/if

Thank you!

Best Regards

Jennifer

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Dynamics Content in E-Mail - Dynamic salutation programming based on a code list

    Hi Jennifer,

    1. You could add an extra block to handle situation that the option set field value not equals to 1 or 2.

    There are 5 options in Gender field of Contact:

    pastedimage1586930871250v1.png

    Overview of dynamic expression:(do nothing in else condition)

    pastedimage1586930938000v2.png

    Result 1:(when the field is "Male")

    pastedimage1586931409802v6.png

    Result 2:(when the field is "Female")

    pastedimage1586931449315v7.png

    Result 3:(when the field is "Gender neutral")

    pastedimage1586931006142v3.png

    Result 4:(when the field is "Alien")

    pastedimage1586931120509v4.png

    Result 5:(when the field is "Unknown")

    pastedimage1586931167249v5.png

    2. I also tested your new expression:

    ---------------------------------------------------------------------------------------------------------------

    {{#if (<operator> <value1> <value2>)}}

      Content displayed when the expression is true

    {{else if (<operator> <value1> <value2>)}}

      Content displayed when the first expression is false and the second one is true

    .

    .

    .

    {{else}}

      Content displayed when all expressions are false

    {{/if}}

    ---------------------------------------------------------------------------------------------------------------

    It will display gender directly if gender not equals to neither Male or Female.

    pastedimage1586932000079v8.png

    result 1: (Gender neutral)

    pastedimage1586932123041v10.png

    result 2: (Alien)

    pastedimage1586932058062v9.png

    Could you describe details that why couldn't you render expected result by running one-by-one?

    From my test, if the field contains data(an option is selected), then it shall display content when specific condition meets.

    For your final doubt "Is there a problem if the field with the option set is empty?":

    Yes, it is an issue in current Marketing application, because dynamic expression is built with Handlebarsjs, 

    If "#if" argument returns null, Handlebars will not render the block, that's by design.(In pure HTML page, we can solve it by extending custom javascript code, but javascript is blocked in HTML email.)

    we need to wait for this issue could be fixed in future version.

    So back to your question, make sure that Gender field of contact record contains a value.

    Regards,

    Clofly

  • Jenni221 Profile Picture
    Jenni221 140 on at
    RE: Dynamics Content in E-Mail - Dynamic salutation programming based on a code list

    The documentation says the following should work. I'm running this one-to-one, but I can't. Is the documentation wrong?

    docs.microsoft.com/.../dynamic-email-content

    {{#if (<operator> <value1> <value2>)}}

      Content displayed when the expression is true

    {{else if (<operator> <value1> <value2>)}}

      Content displayed when the first expression is false and the second one is true

    .

    .

    .

    {{else}}

      Content displayed when all expressions are false

    {{/if}}

    Is there a problem if the field with the option set is empty for a contact? It is not a mandatory field and in case it is not filled I need a third option.

  • Jenni221 Profile Picture
    Jenni221 140 on at
    RE: Dynamics Content in E-Mail - Dynamic salutation programming based on a code list

    Dear Clofly,

    Thanks for your answer.

    The request is quite simple, so that you don't have to program out all possibilities of the If statement, but can only trigger certain actions on 2 defined values and a standard text is displayed for the rest.

    If it is a code list with ten values, your proposed solution becomes quite complex and inflates the template. This is not nice for the end user.

    A nested if statement is standard in my view and should be supported.

    Thank you!

    Best Regards

    Jennifer

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Dynamics Content in E-Mail - Dynamic salutation programming based on a code list

    Hi Jennifer,

    Could you share me your requirement that why would you like to combine two conditional statements instead of a simple checking directly?

    From my test, we could add another "else if" statement directly if there are 3 options in optionset field.

    pastedimage1586847112472v1.png

    Logical expression:

    pastedimage1586847159421v2.png

    Preview:

    pastedimage1586847214678v3.png

    The actual expression should be {{#if A}}{{#if B}}<DisplayedContent>{{/if}}{{/if}} if our expected checking condition is {{#if A and B}}<DisplayedContent>{{/if}

    pastedimage1586847425661v4.png

    Regards,

    Clofly

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans