Skip to main content

Notifications

Announcements

No record found.

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

Custom Code in Marketing Email for Multi-Optionset

Posted on by 125

Hi all,

I'm struggling with the custom code in Dynamics Marketing Marketing Emails.

In the marketing emails it is possible to include dynamic conditions, when content is displayed to customers or not. It is handled with handlebar.js:

 https://docs.microsoft.com/en-us/dynamics365/marketing/dynamic-email-content#conditional-statements-and-comparisons

Unfortunately, it looks like it is not possible to make a condition for multi-option sets, because the operator "equals" does not work here. The following message appears in Dynamics Marketing then:

pastedimage1594880226475v1.png

The conditional statement I've used:

{{#if (eq contact.orb_department 169810000 )}}Marketing{{/if}}

The field itself is a Multi-Optionset on the contact entity, with the following details:

Department orb_department Marketing 169810000
    Sales 169810001
    Service 169810002

I want to only show those people in the Marketing Department a specific content block.

I also tried it with each-loops, unfortunately withouth success:

{{#each contact.orb_department}}
    {{#if this.169810000)}}Result{{/if}}
{{/each}}
Does anybody know, if conditional statements for multi-optionsets would be possible?
Thanks in advance, Carolin
  • Verified answer
    Carolin Profile Picture
    Carolin 125 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Clofy,

    thanks a lot for all the information!

    I've created an Idea for it: experience.dynamics.com/.../

    (Pls vote :) )

    Kind regards, Carolin

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Carolin,

    In Handlebars.js, there is no built-in "contains" helper, thus we need to create a custom one.

    https://axiacore.com/blog/check-if-item-array-handlebars-547/

    https://stackoverflow.com/questions/15497794/handlebars-if-value-contains-x

    However, in Dynamics Marketing email, as documentation listed: currently available syntaxes are limited, and we couldn't register custom helper in email source code.

    You could submit your requirement to Ideas forum.

     Regards,

    Clofly

  • Carolin Profile Picture
    Carolin 125 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Clofy, thanks a lot for your explanation!

    Maybe it is easier with a screenshot from the advanced find:

    Currently the condition only works when the follow is met:

    pastedimage1595233451826v1.png

    But it should work with the following operator:

    pastedimage1595233481378v2.png

    How is that possible?

    Thanks in advance, Carolin

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Carolin,

    I misunderstood what you said.

    Actually the check condition still applies to multi-selected case, just with following format:

    {{# if (eq contact.cre8d_socialmedia '292080000,292080001') }} (<!-- --> comment is optional.)

    pastedimage1595227145206v1.png

    pastedimage1595227176578v2.png

    Result, each option will be separated with commas automatically.

    pastedimage1595227194583v3.png

    Regards,

    Clofly

  • Carolin Profile Picture
    Carolin 125 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Clofy,

    Thank you for the fast response. But for most of the contacts, there are more than one option ticked in the multi-optionset (therefore it is a multi-option-set ;) ) - then it won't work, or? And there is no other solution for it?

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Code in Marketing Email for Multi-Optionset

    Hi Carolin,

    Make sure there is only one option be selected in the multi-optionset field of contact,

    then add single quotation marks to value.

    pastedimage1594889468177v2.png

    It works for me.

    pastedimage1594889501898v3.png

    pastedimage1594889518617v4.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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans