Dynamics 365-learn To Send An Email On Record Share

  • 2Min to Read

One of the common things people do in Dynamics 365 is share a record such as Lead, Opportunity etc. with other users. So how does a user know that a record has been shared with him/her?

This was asked by one of our customer’s. They said “I cannot call and tell that I have shared a lead with you”. Since emails are an integral part of most users’ days, it makes sense that Dynamics 365 should have the capability to send an email notifying the user that record has been shared with him/her. But sadly there was no out-of-box configuration that allows such notification in Dynamics 365.

To solve this, we had to look at our good friend ‘plugin’, so we decided to write a plugin in order to send an email notification when a record is shared.

Sending email was the easy part but there was very little information that we found on which event to trigger the plugin and how to get the details of users with whom the record is being shared.

Table of Contents


Create a plugin project as you would normally do. We used the Dynamics 365 Developer toolkit to do the same. Whenever a record is shared “Grant Access” message is fired so check if the context message is Grant Access (i.e. plugin is executed for ‘Grant Access’)

Get the user who has shared the record by checking the context under which the plugin is running.

Now the tricky part – Get the user with whom the record is being shared. This is found under the “Principal Access” parameter in the plugin context.

In our case as Lead was being shared so get the Lead record that is being shared.

Now we have the user who shared the record, user with whom the record is shared and the record that is shared, so you can now simply create an email message and send email notification from plugin.

Although simple but it is a really handy solution for a common requirement.So that’s it from Soluzione Inc. This is our first blog and hope you like it. If you want additional services then check out Soluzione Inc Microsoft Dynamics CRM Development and Digital Marketing Services.