Dynamics 365 share record content via email:
Let's have an example that you want to share information of a record (account, contact, activity, ...) to a person who can't view the record in CRM due to some issues (such as security, system issue, ...) or he doesn't have access to CRM because organization want to minimize the number of users. Hence, I would like to propose a solution: Implement a Power Automate that will capture all information of record then send it to the receiver via email and in this article, I will show you how to implement an on-demand Power Automate to achieve the requirement as well as how to get Dynamics 365 attachments and my experience in Power Automate.
You can read this chronicle about Power Automate
Prerequisite: you must have basic knowledge about MS Power Automate, you could find it here.
- Enable On-demand MS Power Automate
- Enable MS Power Automate
- How to get Dynamics attachments in MS Power Automate
- Share record information to a user via email
2. Enable On-demand Power Automate
The purpose of this step is to enable button Flow in Dynamics form. After activation is done, there is a button that will display in form as following:
If your Dynamics 365 version contains the October 2019 update, you could skip this step because it's enabled already.
- Navigate to Setting -> Administration -> System Settings -> Customization then click on "Yes" under "Enable Microsoft Flow". You can't change it to No once it's enabled.
- Open Power Platform Admin Center then select environment name -> Settings -> Product -> Behavior and make sure that "Show Power Automate on forms and in the site map" is turned on.
3. How to get Dynamics 365 attachment in Power Automate
First, It is very common when an activity record contains attachments so we need to know how to get Dynamics 365 attachments from Microsoft Power Automate.
Because attachments are stored in notes and displayed in the Timeline section of the activity record, we must retrieve notes associated with the activity record and we could get attachment content from the Note. Since there are a couple of attachments related to a record, we need a variable to store all attachment content.
- Initial variable to store all attachment content:
- Select action List rows then config for "Filter Query" as following
- Loop each note to get the content of Attachments and store to array Attachment content.
Now we have all attachments related activity in variable "lstAttachment", you could use this attachment to upload a file to another system such as "Blob Storage" or send an email with attachments, ...
4. Share Phonecall information to a user via email
The idea is to capture all information of phone call and put them to email body and append it with the attachments we retrieved in previous steps.
Besides that, I propose to create an email template with a HTML page and store it in a technical config entity. It will not only gives an interactive view to the users but also simplify the maintenance when we want to apply some modifications.
The picture below show how we store the template and give a preview on the final rendering.
Then, the steps will be:
- Create on-demand Power Automate: create an instant Cloud Flow and choose the trigger "When a row is selected". In this case we don't need any more input for the trigger
- Get email template from technical config entity: use action "List rows" to retrieve email template from technical config entity. As you could see, there is a field name "new_key" in the technical config entity to store the key. Although there is only one config record to store the PhoneCall template email, I must use a loop to get this record because the output of action "List rows" is an array.
- Get information of phone call: use the action "Get row" and config Phone call ID as input. In this step, you could see that we are able to get the field's value of Phone call from the output of action "When a record is selected" and a question is risen in your mind "Why do we need to retrieve again record?". The reason is: the output of "When a record is selected" doesn't contain full attributes in case the entity has a lot of fields.
Please have a look at the trick How to get optionset's label, name of a lookup value in Flow
- Get attachments of phone call: as explained previously
- Send email: use action Send an email (V2), you could find the detail from MS document
Configuration for Send Email :
- To: address of receiver email. In my example, I send it to the person who runs the Power Automate
- Body: strEmailContent is a string of email template stored in the technical config then replace with data of phone call record
- Attachments: press the button on the right side to switch to the entire array then put value of list attachments content
Here is the final result from the received email when the PA ran:
Here is an example showing how to leverage Power Automate to adapt the requirements and some tips from my experience while doing projects. Do you have another idea to meet the requirement or your tips, let drop a comment to discuss :).
Besides that, MS Power Automate is a very powerful tool that MS provide to User in a various useful case with the purpose to reduce code at least at possible.
Dynamics 365 share record content via email
Is there any extra license required to use Power Automate in D365 Sales?
No need extra license
Hi Amanda Wu,
Most of flow I used in this article is standard flow and no need extra license. However, Microsoft update these flow frequently because it is still new feature and need improving and they could merge some trigers to one or separate it. If you could not find these triggers (or actions), please try to search it by some input such as "when selected record" or try to create a flow inside a solution (some action/trigger just exist when you create a flow inside solution).
Hope it could help you.