Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer Insights - Journeys forum

Dynamic email content from related record (1:N)

(0) ShareShare
ReportReport
Posted on by

Hi,

Contact has 1:N relationship to Opportunity, meaning that one contact can have many opportunities.

We want to send an email to contact automatically when opportunity is closed.

The email should include dynamic content from the recently closed opportunity (eg. estimated revenue)

What's the best way to achieve this?

Thanks for your inputs,

Tiina

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Dynamic email content from related record (1:N)

    Hi Tiina,

    A correct code shall below:

    {{#each contact.contact_opportunity.opportunityid}}

    {{#if (eq this.statecode 1)}}

    <li>Won: {{this.name}}</li>

    {{else if (eq this.statecode 2)}}

    <li>Lost: {{this.name}}</li>

    {{/if}}

    {{/each}}

    Actually, Won/Lost /Open status is represented with int num and status logical name is statecode.

    Now i get trouble in setting a 1:N relationship between contact and opportunity, I found existed relationships in customization for contact entity and opportunity as related entity,

    however these existed relationship can't be proper statement for for-each loop.

    Once a correct relationship could be set, then we would get expected results.

    Since dynamic content is contextual, it would only show current contacts related records.

    Regards,

    Clofly

  • RE: Dynamic email content from related record (1:N)

    Thanks for your answers!

    Pravin: I'm aware that it is possible and fairly easy to trigger email send & include dynamic data from related entity with ClickDimensions. This is a big strength of ClickDimensions :)

    However, I'm currently trying to figure out if similar can be achived with Dynamics for Marketing. This is a feature very much needed in many real-life business-scenarios. For instance: every time a new product is purchased, customer should get an email with data from that specific purchase. Not every purchase in customer history, but only this one specific purchase.

    Clofly: I'll try out the custom code you sent me, but I'm afraid it will include a list of all won open opportunities for that customer with for each - loop, whereas we only want to retrieve the one specific opportunity, recently closed as won. But I'll try that out and see how it goes! Also testing out the "recurring" Customer Journey scenario, because email should be sent to contact EACH TIME when opportunity is won. For non-recurring Customer Journeys I've understood that each contact gets processed only once, no matter how many times they end up in the segment.  

    Tiina

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,231 on at
    RE: Dynamic email content from related record (1:N)

    You could achieve this by using OOB workflow. On status update of opportunity you can send email to contact.

    Please refer below url for reference:

    blog.clickdimensions.com/.../

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Dynamic email content from related record (1:N)

    Hi Tina,

    Marketing email in Dynamics 365 works quite differently from the person-to-person messaging, you could read the doc about its working scenarios. 

    For your scenario, we could achieve it with such steps:

    1. Enable marketing insights service for Opportunity entity, see here for how this service works and how to enable it. Or you could read my previous post for how to enable it and what should we note.

    2. Create a dynamic segment with criteria as below:(Send emails to contacts whose opportunities status are Won or Close)

    (Only when we enable insight service for Opportunity in previous step, it can be available in drop-down selet list)

    pastedimage1563344622781v1.png

    3. Add dynamic content to marketing email with Assis-edit, and write code below with conditional statements and for-each loops. See here for how to apply advanced dynamic contents.

    <p>You closed opportunities:</p>
    <ul>
    {{#each contact.contact_opportunity_opportunityid}}
    {{#if (eq this.status 'Won')}}
    <li>{{this.name}}</li>
    {{else if (eq this.status 'Close')}}
    <li>{{this.name}}</li>
    {{/if}}
    {{/each}}
    </ul>
    4. Set up a recurring customer journey and add previous segment and marketing email.

    There may be delay when contacts receive their emails. 

    Hope it helps.

    Regards,

    Clofly

  • RE: Dynamic email content from related record (1:N)

    Hi Clofly,

    Thanks for your reply!  I'm familiar with triggering email send with workflow, but we need to send an HTML email with header, footer and other formatting that could easily be achieved with Marketing Emails of Dynamics 365 for Marketing.  Including some dynamic data from the opportunity entity (or any other entity which is related to contact with 1:N relationship).

    Is there any way to achieve this with Dynamics for Marketing emails ?

    Thanks in advance!

    Tiina

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Dynamic email content from related record (1:N)

    Hi Tiina,

    You can achieve it with workflow just as you did in Dynamics 365 CE.

    1. Navigate to Advanced Settings at upper right setting icon.

    001.jpg

    2. You will see legacy admin Settings interface. Go to Process Center > Process

    002.jpg

    3. Set trigger entity to Opportunity, and criteria is when its status changes to Won or Close, then add Send email step.

    003.png

    4. An email with dynamic content would like below:(Dynamic Values Assist can be found on upper right )

    004.png

    5. An test opportunity and I close it as Won.

    005.png

    6. My test contact received notification email for several minutes after I closed the opportunity.

    006.png

    Hope it helps.

    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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans