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
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
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
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:
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)
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.
There may be delay when contacts receive their emails.
Hope it helps.
Regards,
Clofly
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
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.
2. You will see legacy admin Settings interface. Go to Process Center > Process
3. Set trigger entity to Opportunity, and criteria is when its status changes to Won or Close, then add Send email step.
4. An email with dynamic content would like below:(Dynamic Values Assist can be found on upper right )
5. An test opportunity and I close it as Won.
6. My test contact received notification email for several minutes after I closed the opportunity.
Hope it helps.
Regards,
Clofly
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156