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,...
Answered

Custom Code in Marketing Email for Multi-Optionset

(0) ShareShare
ReportReport
Posted on by 127

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
I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    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

  • Carolin Profile Picture
    127 on at

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

    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
    127 on at

    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

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    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

  • Verified answer
    Carolin Profile Picture
    127 on at

    Hi Clofy,

    thanks a lot for all the information!

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

    (Pls vote :) )

    Kind regards, Carolin

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 171 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 83

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans