Skip to main content

Notifications

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

Dynamic content in marketing e-mail using if-condition

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello forum,

We want to sent out an e-mail marketing campaign using a custom entity for Promotional Offers related 1:n to Contacts.
On some blocks of the content, I have added custom code tile in order to perform the IF conditions in order to display or not the content depending on Contact type of Promotional Offers enrolled. If condition is fullfilled, than the related block should be displayed, otherwise it should not be displayed (in order to have one single e-mail, but with different displayed content for different contacts).

The custom code is:

<p>{{{#if (eq contact.new_angemeldetesmitgliedid 'Dynamics 365 Customer Engagement')}}<display: block>
              {{else}}<display:hidden>
                         </display>
              {{/else}}
      {{/if}}
</p>

After triggering a customer journey to a sample data, the content is displayed the same regardless of the condition.

Could you please help with the solution?

Kind regards,
Jola

  • slx Profile Picture
    slx 386 on at
    RE: Dynamic content in marketing e-mail using if-condition

    Can you use embedded syntax [tag:each] / [tag:if] or how it can be done ?

    Example

    <!--Personalised comment-->

    <!-- [tag:each] CONDITION -->

    <!-- {{[tag:if] (eq contact.new_angemeldetesmitgliedid 'e3c37e56-78b4-ea11-a812-000d3abaa63a')}} -->

    (Code of block content)

    <!-- {{/if}} -->

    <!-- {{/each}}-->

    <!--End of personalised comment-->

    Regards,

  • Suggested answer
    Preeti Rana Profile Picture
    Preeti Rana on at
    RE: Dynamic content in marketing e-mail using if-condition

    Hi Jola,

    Can you confirm if the modified code worked for you? If not, can you please create a support ticket for this issue so that the team can investigate?

    Guidance on creating ticket: mbs.microsoft.com/.../CRMSupport

    Please email us the ticket number on d365mktcomm@microsoft.com to follow up. :)

    Thanks,

    Preeti Rana

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Dynamic content in marketing e-mail using if-condition

    Hi Jola,

    Thanks for your feedback.

    As you said, we can also add code in html editor without having to add custom code tile.

    Could modified code work for you now?

    Regards,

    Clofly

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamic content in marketing e-mail using if-condition

    Hello Clofly,

    thank you for your answer and explanation.

    For  us, the best way worked with inline code in html editor rather than a custom code tile. In additional to the code displayed and edited as you suggested, it was needed the starting comment:

    <!--Personalised comment-->

    <!-- {{#if (eq contact.new_angemeldetesmitgliedid 'e3c37e56-78b4-ea11-a812-000d3abaa63a')}} -->

    (Code of block content)

    <!-- {{/if}} -->

    <!--End of personalised comment-->

    Regards,

    Jola

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Dynamic content in marketing e-mail using if-condition

    Hi Jola,

    You said that relationship between Contact and custom Promotional Offer entity is N:1, so it seems that you condition is based on a lookup field of Contact entity?

    If so, due to the original value of lookup field is saved in GUID value format of the selected record, so we should do condition checking based on GUID. 

    e.g:

    Show different contents based on contacts' company.

    pastedimage1592981601906v1.png

    Get the guid of company in URL parameter

    2860.JPG

    Dynamic expression in marketing email:

    {{#if (eq contact.parentcustomerid '10dcede8-e4b5-ea11-a812-000d3ab64f2b')}}
    
    Hi Clofly, we prepared a special gift for you.
    
    {{else}}
    
    Hi {{contact.firstname}}, it is glad that you can join us.
    
    {{/if}}

    pastedimage1592981723459v2.png

    Result in preview mode

    If contacts' company is equal to a specific company:(<display:block> in your case)

    pastedimage1592981815170v3.png

    else condition:(<display:hidden> in your case)

    pastedimage1592981885093v4.png

    If I set the value to accounts' name directly, then it always show content of else clause.(<display:hidden></display>)

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans