web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Dynamic content in marketing e-mail using if-condition

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    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

  • Community Member Profile Picture
    on at

    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
    25,210 on at

    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

  • Suggested answer
    Preeti Rana Profile Picture
    on at

    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

  • slx Profile Picture
    386 on at

    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,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans