Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Advanced Custom code If and else setting in a marketing email

(0) ShareShare
ReportReport
Posted on by 235

Hi, 

I would like to send an email to a group of customer. One group should get One email and the other the other

My email contains 2 block

The field I am trying to get is a 1:N relationship from contact. 

Kind regards

Camilla

  • slx Profile Picture
    slx 386 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Could we add datetime in a condition ?

    <!-- #if (gt this.createdon '2023-01-01') -->

    ?

    thank you

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Hi Camilla,

    If you have new question, please open a new thread for it, I'll answer you in that new thread. :)

    (And please add more descriptions or an example towards the new question.

    As per my understanding, it seems that you would like to display different content based on value of two fields?

    Or is the new question still related to marketing email?)

    Regards,

    Clofly

  • Camilla Larsson Profile Picture
    Camilla Larsson 235 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Camilla

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Hi Camilla,

    I sent test email to two different contacts, and result is as expected.

    (Due to relationship between Contact and Memebership is 1:N in my environment, so I instead tested by Conatct and Account(Company Name))

    pastedimage1590474724542v1.png

    Bulk Email field of Cloflys' company is Allow(false, its default setting.)

    pastedimage1590474749845v2.png

    Bulk Email field of Viktors' company is Do Not Allow(true)

    pastedimage1590474909468v3.png

    Your issue might be caused by cache, try to run a simple customer journey again to send email to your two test contacts,

    make Roadassistance field of memebership of those two contacts have opposite value, then check whether content of delivered email would become different.

    Regards,

    Clofly

  • Camilla Larsson Profile Picture
    Camilla Larsson 235 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Hi again, 

    Now I`ve got the email number 2, sent to my private email adress. This person has Roadassistance= No, But still he got this. (The conatct with my email is a he). 

    I`ve also got this but I have Roadassistance= Yes?

  • Camilla Larsson Profile Picture
    Camilla Larsson 235 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Thank you so much for your help Clofly. This custom code is not easy for a person that don`t works with code. But hopefully I will get this.. Really hope Microsoft came with something eaiser.

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Advanced Custom code If and else setting in a marketing email

    Hi Camilla,

    Yes, you will always get the Content B Text if Roadassistance = Yes.

    If you change roadassistance of membership to No, then you will get Content A.

    Regards,

    Clofly

  • Camilla Larsson Profile Picture
    Camilla Larsson 235 on at
    RE: Advanced Custom code If and else setting in a marketing email

    ..

  • Camilla Larsson Profile Picture
    Camilla Larsson 235 on at
    RE: Advanced Custom code If and else setting in a marketing email

    The dynamic expression is Yes/No..

    But now you lost me again.. This is not easy.. How should I write this?

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Advanced Custom code If and else setting in a marketing email

    It is based on value of cgi_roadassistance field.

    Could you share your dynamic expression?

    {{#if contact.xxx}} expression is equal to true.

    e.g: If cgi_roadassistance of related membership is yes, then your expression would be

    {{#if  contact.contact_cgi_membership_cgi_currentmembershipid.cgi_roadassistance }}  

           Veihjelp 1

        {{else}}

          Veihjelp 2

    {{/if}}    

    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... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans