One of the common things people do in Dynamics365 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 Dynamics365 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 Dynamics365.
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.
Create a plugin project as you would normally do. We used the Dynamics365 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. This is our first blog and hope you like it.If you want additional services then check out Soluzione Digital Services.