
Using Power Automate to send emails to a dynamic list of people in a timeline
Reading time: 2 - 3 minutes
The standout feature of DataVerse emails is their appearance in your timeline. While there might be hacks to get Outlook-generated emails into Microsoft Dynamics 365 CRM, using a DataVerse Email record is the simplest way. For those unfamiliar, the timeline displays the ongoing history and activities of a record, showing everyone's interactions with Accounts, Contacts, Cases, etc.
When designing systems for customers, most emails don't need to appear in the timeline. They usually inform users about new Opportunities, Cases, or other events. However, some clients now want these emails in their timeline, making DataVerse email essential, despite its storage space usage.
Compose the rest of the email with the Case in the Regarding field and relevant details in the Subject and Description fields. However, I encountered a problem: some Cases were team-owned, causing failures.
To resolve this, I split the process into user-owned and team-owned branches. The user-owned branch followed the previous process, but the team-owned branch needed to send emails to all team members. Looping through each member would flood the timeline with emails, so I needed a single email.
Most of the email was going to be the same as above, the difference would be who’s included in the email and the greeting. Clicking on the toggle next to the activity parties, I could see that I could form a dynamic activity party list but really struggled to find how to do this – there just wasn’t any information out there.
My plan was to:
- Use a List step to go through all team members of the owning team;
- Append each team member's email address or GUID to a variable.
- Use this variable to send an email to everyone.
First, I created a variable for the array that I needed to append. Then, I used the List step to go through team members, manually entering the table name and using the team's GUID as a filter.
With an 'Apply to Each' step, I listed all team members and translated them into activity parties. I found a promising snippet online:
{
"participationtypemask": 1,
"
}
The party ID was straightforward: fill in the table type and GUID, like a Power Automate lookup. The activity type mask specifies the activity party type. For emails, the relevant types are:
- Sender: 1
- ToRecipient: 2
- CCRecipient: 3
- BccRecipient: 4
In the 'Apply to Each' step, I appended each run to the variable with 2 in the participationtypemask and the user's GUID in the Party ID. Finally, I added the 'from' party with a single append, updating the participationtypemask to 1. Adding more people to the list is now straightforward.
Testing this, I used a 'compose' step to see the generated array. It looked messy, filled with control characters, but I hoped it was due to writing an array to a text field. I tested it with an email (without sending it), and it worked perfectly on the first try.
That's how to create an email for a dynamic list of people that appears in the Timeline!